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.
Answer Posted / d289
The error is in x not being referenced/initialized properly.
| Is This Answer Correct ? | 1 Yes | 4 No |
Post New Answer View All Answers
Can non-public members of another instance of the class be retrieved by the method of the same class?
Does there exist any way to make the command line arguments available to other functions without passing them as arguments to the function?
What is extern c++?
Do you know about latest advancements in C++ ?
What is a dynamic binding in c++?
How would you implement a substr() function that extracts a sub string from a given string?
Why c++ is better than c language?
What is c++ stringstream?
What is main function in c++ with example?
What do you mean by funtion prototype?
What relational operators if statements in c++?
If dog is a friend of boy and boy is a friend of house, is dog a friend of house?
Which programming language is best to learn first?
What does flush do?
Are there any special rules about inlining?