Which is most appropriate comment on following class definition? [code] class Student { int a; public : float a; }; [/code]

Which is most appropriate comment on following class definition?
Code:
class Student 
{
    int a; 
    public : float a; 
};
A. Error : same variable name can’t be used twice
B. Error : Public must come first
C. Error : data types are different for same variable
D. It is correct
 
Answer: a
Explanation: Same variable can’t be defined twice in same scope. Even if the data types are different, variable name must be different. There is no rule like Public member should come first or last.
 

Tìm kiếm

Back
Top