Copy Constructoy With Perameter Example in C++ Programming with source code
#include<iostream.h>
#include<conio.h>
//Def: Copy Constructoy With Perameter.
class second
{
private:
int a,b;
public:
second()
{
a=0;
b=0;
}
second(int x,int y)
{
a=x;
b=y;
}
second(second &s)
{
a=s.a;
b=s.b;
}
void display()
{
cout<<"\nThe Value of A=>"<<a<<endl;
cout<<"\nThe Value of B=>"<<b<<endl;
cout<<"\nThe Total Of All=>"<<a+b<<endl;
}
};
void main()
{
int a,b;
clrscr();
cout<<"\nEnter The Value of A=>";
cin>>a;
cout<<"\nEnter The Value of B=>";
cin>>b;
second s1(a,b);
second s2(s1);
s1.display();
s2.display();
getch();
}
#include<conio.h>
//Def: Copy Constructoy With Perameter.
class second
{
private:
int a,b;
public:
second()
{
a=0;
b=0;
}
second(int x,int y)
{
a=x;
b=y;
}
second(second &s)
{
a=s.a;
b=s.b;
}
void display()
{
cout<<"\nThe Value of A=>"<<a<<endl;
cout<<"\nThe Value of B=>"<<b<<endl;
cout<<"\nThe Total Of All=>"<<a+b<<endl;
}
};
void main()
{
int a,b;
clrscr();
cout<<"\nEnter The Value of A=>";
cin>>a;
cout<<"\nEnter The Value of B=>";
cin>>b;
second s1(a,b);
second s2(s1);
s1.display();
s2.display();
getch();
}
Copy Constructoy With Perameter Example in C++ Programming with source code
Reviewed by Unknown
on
5:57:00 PM
Rating:
c programming example codes for rookies
ReplyDeletec code | Fibonacci numbers