What is the problem or error with the following code snippet and how would it be fixed?
class Car { public: Car() { num = 1; } private: const int num; };
A. You cannot change a const value. You should replace the constructor with the following code: Car(): num(1){}. B. The problem is that the keyword "private" needs to be replaced with "protected”. C. You cannot assign 1 to num. Simply removing the line "num = 1" will correct the problem. D. The problem is that there is no destructor with the class. Once you add a destructor for the class, the code will be fine.
Total Answers and Comments: 3
Last Update: December 07, 2008 Asked by: prettyfox