Vidyalelo
C++ Programming · Q39

Introduction to C++

Programming · C++ Programming · question 39

Q39

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

Answer: Option D

Solution

Answer: Option D
No explanation is given for this question Let's Discuss on Board