Lecture 2 - Page 20 : 42
Notes about C++
Basic facilities
Basic facilities
Fundamental types i C++
Booleans
Structs in C++
Declarations and definitions
The structure of a declaration
Declaring several names together
Declarations as statements - declarations in conditions
Constants
The general notation of objects in C++
Lvalues
C-style strings
C++ style strings
Strings - examples
References
Rules for references
References - Examples
Constant References
References versus Pointers
Parameter passing in C++
Value return
Type conversion - Grand Overview
Implicit type conversions
Explicit type conversion
Function Overloading
Function Overloading - more detailed rules
Function Overloading - Examples
Vectors in C++
Vectors - examples
The free store
Input and output in C++
Overloaded operators and IO
Standard streams
Stream State
Manipulators
More manipulators
Logical program organization
More namespaces
Physical program organization
Example of program organization
The standard library namespace
Point Exercise - C++ versus C#
Parameter passing in C++
It is possible to pass parameters by value, by a pointer, and via a C++ reference
Call by value
Copy actual parameters and bind to formal parameters
Formal parameters are
initialized
- not assigned.
For user-defined types: It is possible to control what copying means - via a
copy constructor
In the copy constructor itself, call-by-C++-reference parameter passing is crucial.
Details
in the next lecture
In the special case: Passing pointers by value (C-style call-by-reference)
Call by (C++) reference
The formal parameter becomes an alias of the actual parameter
Call by const reference
is an attractive alternative to
call by value
parameters
No overhead due to copying
No risk of modifying the actual parameter via the formal parameter