18.3 Constructors
(introduced in Chptr. 6)
- Same name as the class
- No return type
- Used to initialize class' attributes
- May be overloaded
- Only one c'tor is invoked at creation
- Implicitly invoked:
- Each time a block is entered where an object is declared
- For static objects - before main starts
- When an object is created on the heap with new
- When an object is passed by value
- For member objects, when aggregate is created
- When child is instantiated
prev
|top
|next