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

which of the following is not an secondary constant a) array b) real c) union

0 Answers  


Is it possible for a member function to use delete this?

0 Answers  


what is difference between internet and Internet?

12 Answers   College School Exams Tests, Microsoft, MIT, TCS,


Define a nested class. Explain how it can be useful.

0 Answers  


Under what conditions is multiple inheritance not recommended?

1 Answers  






What is the difference between = and == in C?

16 Answers   Christ University, Intel,


What is the function to call to turn an ascii string into a long?

0 Answers  


What is atoi?

0 Answers  


What is difference between c++ 11 and c++ 14?

0 Answers  


What is the difference between structures and unions?

0 Answers  


Explain all the C++ concepts using examples.

0 Answers   InterGraph,


Write about a nested class and mention its use?

0 Answers  


Categories