Lecture 3 - Page 7 : 36
Notes about C++
Abstraction Mechanisms, Part 1
From C# classes to C++ classes
Organization of classes and members
Classes, structs and namespaces
Functions outside classes
Constructors
Constructors - initialization versus assignment
More about constructors
Use of constructors
Destructors
A class that needs a destructor
Resource acquisition is initialization - RAII
Auto Pointers
Object copying
Copying Point objects in parameter passing
Example of copying objects: Default copying
Example of copying objects: Programmed copying
Preventing object copying
Classes and Conversion
Implicit Conversion
Classes and Conversion: Examples
Static class members
Const member functions
Const member functions - const and mutable
Object Self-reference
Inline member functions
Concrete classes
Visibility and Access Control
Friends
Friends - Example 1
Friends - Example 2
Friends - class Point - notational convenience
Friends - Class Point - operator friends
Friends - Class Point - implicit conversion
Discussion - Encapsulation, Visibility and Access
Operator overloading
Example: Operator overloading in class Point
More about constructors
Additional properties of constructos in C++
The C++ Programming Language
: Page 226, 247, 270
Overloaded constructors
Constructors can be overloaded, just as other functions
Explicit constructors
By means of an
explicit
specifier before the constructor
Cannot be used in implicite type conversion
Default constructor
In case a constructor is defined there will be no parameterless default constructor
As in C#
Can be called without actual parameters
Either parameterless, or with default values for every parameter
Used for initialization of automatic variables of class type
Copy constructor
A constructor that takes a single reference parameter to its class
Generated automatically - if needed - and if not programmed explicitly