Professional Documents
Culture Documents
c) Find out the output of the following code with proper justification:
#include<iostream.h>
class X
{ public:
int a;
};
class Y: public X
{ public:
int a;
};
void main( )
{
X x,*p;
p=&x;
*p->a=100;
Y y,*q;
q=&y;
(*q).a=200;
X z=y;
cout<<x.a<<y.a<<z.a;
}
g) Find out the output of the following code with proper justification:
#include<iostream.h>
int count=0;
class A
{
public:
A( )
{ cout<<”object constructed:”<<++count; }
~A( )
{ cout<<”object destroyed :”<<count--; }
};
void main( )
{
A a1,a2;
{ A a3; }
{ A a4; }
h) List two operators that can not be overloaded and two operators which
can not be overloaded using a friend operator function.
b) What is data hiding? How can an external function access the [4]
private data members of a class?Illustrate with a suitable example.
6. a) Discuss the different techniques using which one class type can be [5]
converted into another class type.Illustrate with suitable examples.
XXXXX