Saved Bookmarks
| 1. |
Can a constructor be private in C++? |
|
Answer» A constructor is a particular member function of a class that is responsible for initialising the class's objects. When a class object is CREATED in C++, the constructor is automatically invoked. Constructors are typically defined in the public SECTION of a class. So, the question is whether CONSTRUCTION can be defined in the class's private section. The answer to this is a yes. A constructor can be defined in the class's private section. The ways to use a constructor in the private section of the class:
|
|