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
What are mutator methods in c++?
what is Member Functions in Classes?
Is java based off c++?
Which of the following is not a valid declaration for main() a) int main() b) int main(int argc, char *argv[]) c) They both work
Why can’t you call invariants() as the first line of your constructor?
Does c++ support multilevel and multiple inheritances?
Declare a class vehicle and make it an abstract data type.
What is std :: endl?
What is the real purpose of class – to export data?
Explain the static storage classes in c++.
What is new in c++?
What is the benefit of c++?
Is string data type in c++?
What is data hiding c++?
What is a c++ map?