.
Home About-us Privacy Policy Contact-us Services

Thursday, October 8, 2015

C++ Program to concept of copy constructor

ad+1

Program - 


#include<iostream.h>
#include<conio.h>
class abc
{
private:
int a;
float b;
public:
abc(int x,float y)
{
a=x;
b=y;
}
abc(abc&m)
{
a=m.a;
b=m.b;
}
void write(void)
{
cout<<a<<endl;
cout<<b;
}
};
void main()
{
clrscr();
abc m(20,4.2);
abc m2(m);
abc m3=m;
m.write();
m2.write();
m3.write();
getch();
}

Output - 


20
4.220
4.220
4.2




0 comments:

Post a Comment

Home About-us Privacy Policy Contact-us Services
Copyright © 2014 All Programs Examples | All Rights Reserved. Blogger Templates Download Blogger Templates