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.

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести