Thursday, 20 July 2017

class of passing reference of another class

#include<iostream.h>
#include<conio.h>
class sample
{               public:
int i,j;
sample(int a,int b)
  {
i=a;
j=b;
 }
sample(sample&S)
{

j=S.j;
i=S.j;
cout<<"copy constructor\n"<<i<<"\n"<<j<<"\n";
}
void show()
{
cout<<"void show\n"<<j;
}
};
void main()
{
clrscr();
sample S(7,6);
sample s1(S);

S.show();
getch();
}

No comments:

Post a Comment