Examveda

What is the correct syntax to define a class named 'Rectangle' with private member variables 'length' and 'width' in C++?

A. class Rectangle { private: int length; private: int width; };

B. class Rectangle { int length, width; private: };

C. class Rectangle { length, width; private: int; };

D. class Rectangle { private: int length, width; };

Answer: Option D


Join The Discussion

Related Questions on Introduction to C plus plus