Sunday, January 26, 2014

C++ Program using Copy Constructor

with 0 Comment
C++ Program using Copy Constructor:

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class code
{
int id;
public:
code()
{
}
code(int a)
{
id=a;
}
code(code &x)
{
id=x.id;
}
void display(void)
{
cout<<id;
}
};

void main()
{
code A(100);
code B(A);
code C=A;
code D;
D=A;
clrscr();
cout<<"\n id of A ";A.display();
cout<<"\n id of B ";B.display();
cout<<"\n id of C ";C.display();
cout<<"\n id of D ";D.display();
getch();
}

0 comments:

Post a Comment

Powered by Blogger.

Blog Archive