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 the difference between object-oriented programming and procedural programming?

0 Answers  


What is auto used for in c++?

0 Answers  


If dog is a friend of boy, and terrier derives from dog, is terrier a friend of boy?

0 Answers  


What is a try block?

0 Answers  


Explain operator overloading.

0 Answers  


What will happen if a pointer is deleted twice?

0 Answers   Agilent, HAL,


What is a constructor initializer list and when we use constructor initializer list?

3 Answers   Soft Info, TCS,


What is a c++ object?

0 Answers  


What is the Maximum Size that an Array can hold?

55 Answers   Adobe, FutureSoft, HCL, Infosys, Satyam, TCS, Wipro,


What is type of 'this' pointer?

0 Answers  


what are the characteristics of Class Members in C++?

0 Answers  


How a new element can be added or pushed in a stack?

0 Answers  


Categories