C++ output type question
Q. C++ : Trace the output.
class base
{
private: int x;
protected: int y;
public:
base()
{
x=10;
y=20;
}
};
class derived : public base
{
protected:
int a, b;
void change( )
{
a=x;
b=y;
cout << a << b;
}
};
void main()
{
derived obj;
obj.change();
}
- Published on 23 Jun 15a. 10 20
b. Run time error.
c. Compile time error.
d. None of the above
ANSWER: Compile time error.