Lecture 2 - Page 5 : 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#
Declarations and definitions
It is important to be able to distinguish between
declarations
and
definitions
The C++ Programming Language
: Page 78
Declaration
Introduces names and types - for the benefit of the compiler
Several declarations of the same name are allowed - must agree on the types involved
Definition
A declaration that also defines
an entity
A location in memory
A function with a body
There must be precisely one definition of a named entity
The one-definition-rule (ODR) relaxes this a bit - for the benefit of multiple includes:
A class, inline function, or template may be defined more than once
if they appear in different translation units
if they are token-for-token identical
Illustration of declarations and definitions - everything is fine.
Illustration of declarations and definitions - several problems.
The C++ Programming Language
: ODR. Page 203
A definition is a declaration - a declaration is not necessarily a definition