For the following class definition in C++, which lines will cause errors?

class cl
{
  static int x;
public :
  static int y;
  static void f2();
  void f1();
};

int cl::x=1;
int cl::y=2;
void cl::f1()
{
    x++; y++; // 1 
}
void cl::f2()
{
  x++; y++; //2 
}
void f3()
{
    cl::x++; cl::y++; // 3
}
Explanation
Line number 3, since the function outside the class has only access to public class variables.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes