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 is enum c++?
Difference between pointer to constant and constant pointer to a constant. Give example.
Can class objects be passed as function arguments?
How does the copy constructor differ from the assignment operator (=)?
What is std :: endl?
Is c++ the hardest language?
What is extern c++?
What c++ is used for?
Can malloc be used in c++?
Can a class be static in c++?
Describe the role of the c++ in the tradeoff of safety vs. Usability?
What is the use of data hiding?
What is the most powerful coding language?
What does the following do: for(;;) ; a) Illegal b) Loops forever c) Ignored by compiler...not illegal
Is C++ case sensitive a) False b) Depends on implementation c) True