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


Please Help Members By Posting Answers For Below Questions

What does 7/9*9 equal ? a) 1 b) 0.08642 c) 0

578


What is tellg () in c++?

717


Can c++ be faster than c?

597


How is data hiding achieved in c++?

567


Can member data be public?

594






What is guard code in c++?

633


What are c++ tokens?

590


What are the four main data types?

579


What is the most useful programming language?

601


write a corrected statement so that the instruction will work properly. if (4 < x < 11) y = 2 * x;

1510


How do I use arrays in c++?

582


Write a program to add three numbers in C++ utilizing classes.

619


Why is c++ considered difficult?

641


Why do we use double in c++?

592


What does the nocreate and noreplace flag ensure when they are used for opening a file?

673