Constructor Destructor – C++ Programming Interview Questions

(Last Updated On: June 12, 2017)

C++ tricky and conceptual programming interview questions  and answers on constructor and destructor with explanation asked in technical interviews.

Topic – Constructor and Destructor

 


Q-In below class, write a constructor to initialize const data member.

Answer: To initialize a const data member we need to use initializer list in the class constructor.

We can not initialize const data member in C++ using assignment operator in constructor e.g.

Example: correct way to initialize const data