C++ Programming

¡Supera tus tareas y exámenes ahora con Quizwiz!

include guard

(#ifndef) prevents the header file from accidentally being included more than once. (helps to prevent multiple definitions of an entity by selectively enabling/disabling the code they surround)

C++ filename extensions

.cc, .cpp, .cxx, .c++, .h, .hh, .hpp, .hxx, .h++

mutable

A data type in which the elements can be modified. It is allowed to assign a value to this mutable variables from a const member function.

header file

A file typically containing type, class and/or standalone function declarations, as well as constants, with little or no active code, designed to be included in source files that are clients of the declared types, classes or functions.

inline function

A function defined in the body of a class declaration is an inline function.

virtual function

A member function that may be overridden in a derived class and for which runtime polymorphism is used.

preprocessing directive

A message to the C++ preprocessor. They are invoked by the compiler to process some programs before compilation.

assembler

A program that translates an assembly-language program into machine code (binary)

this pointer

A special predefined pointer that is assigned to the implied (invoking) object.

break statement

A statement that causes a loop to terminate early.

continue statement

A statement that causes the remainder of the current iteration of a loop to be skipped. The flow of execution goes back to the top of the loop, evaluates the condition, and if this is true the next iteration of the loop will begin.

struct

A structure type is a user-defined composite type. It is composed of fields or members that can have different types. A structure is the same as a class except that its members are public by default.

volatile

A type qualifier that you can use to declare that an object can be modified in the program by the hardware.

union

A user-defined type in which all members share the same memory location. At any given time, a union can contain no more than one object from its list of members. No matter how many members a union has, it always uses only enough memory to store the largest member.

new operator

Allocates memory for an object or array of objects of type-name from the free store and returns a suitably typed, nonzero pointer to the object.

escape sequence

An escape character (\) followed by special characters that do not behave in accordance to standard output streams.

lambda expression

An expression used to define an anonymous function. Often used to create functions that are passed as arguments to other functions.

C++ language family

C-styled language

delete operator

Deallocates a block of memory.

auto

Deduces the type of a declared variable from its initialization expression.

extern

In a non-const global variable declaration, extern specifies that the variable or function is defined in another translation unit. The extern must be applied in all files except the one where the variable is defined. In a const variable declaration, it specifies that the variable has external linkage. The extern must be applied to all declarations in all files. (Global const variables have internal linkage by default.)

std::endl

Inserts a newline character into the output sequence os and flushes it as if by calling os.put(os.widen('\n')) followed by os.flush().

namespace std

The C++ Standard Library provides several generic containers, functions to use and manipulate these containers, function objects, generic strings and streams (including interactive and file I/O), support for some language features, and functions for everyday tasks.

bitwise exclusive OR

The XOR operator (^) compares each bit of its first operand to the corresponding bit of its second operand. If the bit in one of the operands is 0 and the bit in the other operand is 1, the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0.

method overloading

The ability to define two or more different methods with the same name but different method signatures.

std::ios_base

The class ios_base is a multipurpose class that serves as the base class for all I/O stream classes. It maintains several kinds of data: stream status flags, flags that control formatting of both input and output sequences and the imbued locale, indexed extensible data structure that allows both long and void* members, which may be implemented as two arbitrary-length arrays or a single array of two-element structs or another container, and arbitrary number of user-defined functions to be called from imbue(), copyfmt(), and ~ios_base()

stderr

The standard error stream is the default destination for error messages and other diagnostic warnings.

stdout

The standard output stream is the default destination of output for applications. In most systems, it is usually directed by default to the terminal.

sizeof

Yields the size of its operand with respect to the size of type char.

switch statement

a C++ statement that can be used to code a multiple-alternative selection structure

using namespace std;

a bad practice which can cause name conflicts as it pulls in the entirety of the std namespace into the global namespace which can cause namespace pollution

template

a construct that generates an ordinary type or function at compile time based on arguments the user supplies for the template parameters

namespace

a declarative region that provides a scope to the identifiers (the names of types, functions, variables, etc) inside it

std::cin

a filestream variable that represents the default input source

macro

a fragment of code which has been given a name

int main()

a function that marks the beginning and termination of every C++ program

C++

a general-purpose programming language created by Bjarne Stroustrup as an extension of the C programming language, or "C with classes"

precompiled header

a header file that is compiled into an intermediate form that is faster to process for the compiler. Usage of precompiled headers may significantly reduce compilation time, especially when applied to large header files, header files that include many other header files, or header files that are included in many translation units.

heap

a hierarchical data structure that allocates memory randomly; Explicit deallocation is required

stack

a high speed, fixed-size linear data structure that allocates memory in a contiguous block.

#pragma once

a non-standard but widely supported preprocessor directive designed to cause the current source file to be included only once in a single compilation

nullptr

a null pointer constant of type std::nullptr_t, which is convertible to any raw pointer type.

linker

a program that combines the object program with other programs in the library, and is used in the program to create the executable code

compiler

a program that translates code in a high-level language to assembly instructions

goto statement

a statement that transfers control to some other statement, which is tagged with a label.

dynamic_cast

a type conversion operation that performs safe conversions using on run time type information

reinterpret_cast

a type conversion operation that reinterprets the raw memory of an object as a value of another type. The result of a reinterpret_cast can only be portably used after being converted back into its original type.

storage classes

a type specifier that governs the lifetime, linkage, and memory location of objects; extern, static, thread_local

address operator

a unary operator that returns the memory address of its operand

class

a user-defined data type, which holds its own data members and member functions, which can be accessed and used by creating an instance of that class

enum

a user-defined type that consists of a set of named integral constants that are known as enumerators.

public

an access modifier that declares a class or field as available to any function

protected

an access modifier that specifies access to class members in the member-list up to the next access specifier (public or private) or the end of the class definition

private

an access modifier that specifies members are accessible only from member functions and friends of the class

pointer

an object that stores a memory address of another variable or pointer

const

an unmodifiable variable; polar opposite of mutable

friend

appears in a class body and grants a function or another class access to private and protected members of the class where the friend declaration appears

\a

audible bell or alarm

\\

backslash

\b

backspace

bool

booleans can only store true or false

\r

carriage return

#define

causes the compiler to substitute token-string for each occurrence of the macro in the source file

char

characters require 1 byte of memory and ranges from -128 to 127 or 0 to 255

\"

double quote

double

doubles require 8 bytes of memory and can store double precision floating point values

static_cast

explicitly converts (or type casts) data from one data type to another

float

floats require 4 bytes of memory and can store single precision floating point values

\f

form feed; new page

scope resolution operator (::)

helps to identify and specify the context to which an identifier refers, particularly by specifying a namespace

\t

horizontal tab

<iostream>

input-output stream; a library that allows programs to read from stdin and write to stdout.

C++ primitive data types

int, char, bool, double, float, void, wchar_t

int

integers require 4 bytes of memory and range from -2147483648 to 2147483647

\n

line feed; new line

\0

null terminator

C++ paradigms

procedural, functional, object-oriented, generic, modular

\?

question mark

#include

replaces the directive with the content of the file whose name is listed in the directive

return statement

returns a function's value to the statement that invoked the function

\'

single quote

explicit specifier

specifies that a constructor or conversion function is explicit, that is, it cannot be used for implicit conversions and copy-initialization

stdin

standard input stream; information inputted into terminal through keyboard or input device

static

static duration means that the object or variable is allocated when the program starts and is deallocated when the program ends

C++ typing discipline

static, nominative, partially inferred

std::cerr

std::ostream object tied to the standard error, which often writes to the same device as the standard output. By default, writes to cerr are not buffered. Usually used for error messages or other output that is not part of the normal logic of the program.

std::istream::operator>>

stream extraction operator; Extracts and parses characters sequentially from the stream to interpret them as the representation of a value of the proper type, which is stored as the value of val.Internally, the function accesses the input sequence by first constructing a sentry object (with noskipws set to false). Then (if good), it calls num_get::get (using the stream's selected locale) to perform both the extraction and the parsing operations, adjusting the stream's internal state flags accordingly. Finally, it destroys the sentry object before returning.

std::ostream::operator<<

stream insertion operator; Generates a sequence of characters with the representation of val, properly formatted according to the locale and other formatting settings selected in the stream, and inserts them into the output stream.Internally, the function accesses the output sequence by first constructing a sentry object. Then (if good), it calls num_put::put (using the stream's selected locale) to perform both the formatting and the insertion operations, adjusting the stream's internal state flags accordingly. Finally, it destroys the sentry object before returning.

unsigned short int

takes up 2 bytes of memory and is the absolute value of a short integer (0 to 65,535)

short int

takes up 2 bytes of memory and ranges from -32,768 to 32,767

unsigned int

takes up 8 bytes of memory and is the absolute value of an integer (0 to 4,294,967,295)

unsigned long long int

takes up 8 bytes of memory and is the absolute value of an long long integer (0 to 18,446,744,073,709,551,615)

bitwise AND

the bitwise AND operator compares each bit of the first operand to the corresponding bit of the second operand; if both bits are 1, the corresponding result bit is set to 1; otherwise, the corresponding result bit is set to 0

logical OR

the logical OR operator (||) returns the boolean value true if either or both operands is true and returns false otherwise

logical negation

the result of the logical negation operator (!) is true if the converted operand is false; the result is false if the converted operand is true

std::cout

the standard output stream object; used with the insertion operator to display information

exception handling

try, throw, catch; surround the potentially erroneous code with the "try" keyword. Surround the mitigation with a "catch" statement. The "throw" keyword will throw an exception to stderr.

\v

vertical tab

void

void represents a valueless entity; cannot be used for variable declaration

wchar_t

wide characters represent text in fixed-width, multi-byte encodings


Conjuntos de estudio relacionados

Unit Circle - Degrees/Radians/Sine/Cosine/tan

View Set

50 Largest Cities Proper in the World

View Set

CFA Level 1 - Quantitative Methods

View Set

Immune Disorders and HIV NCLEX Review

View Set