class X
{
public:
int x;
static void f(int z);
};
void X::f(int y) {x=y;}
What is the error in the sample code above?
a) The class X does not have any protected members.
b) The static member function f() accesses the non-static z.
c) The static member function f() accesses the non-static x.
d) The member function f() must return a value.
e) The class X does not have any private members.

Answers were Sorted based on User's Feedback



class X { public: int x; static void f(int z); }; void X::f(int y) {x=y;} What i..

Answer / guest

option 'c' is the answer

Is This Answer Correct ?    12 Yes 2 No

class X { public: int x; static void f(int z); }; void X::f(int y) {x=y;} What i..

Answer / d289

The error is in x not being referenced/initialized properly.

Is This Answer Correct ?    1 Yes 4 No

Post New Answer

More C++ General Interview Questions

Can we declare destructor as static? Explain?

3 Answers  


How to allocate memory dynamically for a reference?

0 Answers  


Why is swift so fast?

0 Answers  


What is #include math h in c++?

0 Answers  


What is the difference between a definition and a declaration?

0 Answers  






if i want cin 12345678910 and cout abcdefghij. so how can i create the program?. example : if i key in 8910 so the answer is ghij.

3 Answers  


Do vectors start at 0?

0 Answers  


What are advantages of c++?

0 Answers  


Is it possible to write a c++ template to check for a function's existence?

0 Answers  


What do you mean by const correctness?

0 Answers  


What does the ios::ate argument do?

0 Answers  


Why is c++ not purely object oriented?

0 Answers  


Categories