91. Basics of Classes

Question.1

Two developers write the following code snippets to achieve the same objective:

Code 1

struct S { int x; };

// ... inside main() ...
S s; 
s.x = 10;

Code 2

class C { int x; };

// ... inside main() ...
C c; 
c.x = 10;

Which of these implementations will compile successfully?

Need Help? Refer to the Quick Guide below

Select Answer