1.

What happens if non static members are used in static member function?(a) Compile time error(b) Runtime error(c) Executes fine(d) Executes if that member function is not usedThe question was asked in homework.Origin of the question is Member Functions topic in portion Class Members & Types of Object Oriented Programming

Answer»

Right option is (a) Compile TIME ERROR

The best I can explain: There must be specific memory space allocated for the data members before the static member functions USES them. But the space is not reserved if OBJECT is not declared. HENCE only if static members are not used, it leads to compile time error.



Discussion

No Comment Found

Related InterviewSolutions