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

What is c++ best used for?

0 Answers  


On throwing an exception by the animal constructor in p = new animalq, can memory leak occur?

0 Answers  


What is == in programming?

0 Answers  


What is microsoft c++ redistributable?

0 Answers  


What is the arrow operator in c++?

0 Answers  






Consider the following code fragment: int main(void) { int m = 4; mystery ( m ); mystery ( m ); printf("%d", m); return 0; } What is the output on the monitor if mystery is defined as follows ? void mystery (int m) { m = m+3; }

2 Answers   CDAC, Wipro,


What is #include math h in c++?

0 Answers  


what Is DCS ? what i will get benefit when i did?

0 Answers  


Disadvantages of c++

8 Answers   HCL,


Are there any special rules about inlining?

0 Answers  


CAN U SAY WHICH PROGRAMING LANGUAGE IS USED BY DOCTORS....?

1 Answers  


what is scupper?

0 Answers  


Categories