Friday 1 February 2013

default copy constructor in c++ by zafar iqbal levi

//TAKE ONE BOOK DETAIL AND PRINT ITS COPIES WITH A DIFF OBJECT NAME.
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
class book
{
private:
int page;
float price;
char tittle[50];
public:
void setdata()
{
cout<<"enter tittle            ";
gets(tittle);
cout<<"enter pages             ";
cin>>page;
cout<<"enter price             ";
cin>>price;
}

void showdata()
{
cout<<"tittle                    "<<tittle;
cout<<"\npages                    "<<page;
cout<<"\nprice                    "<<price;
}
};

void main()
{
book b1;
b1.setdata();
book b2(b1);
book b3=b1;

cout<<"\n\ndetails of book b1\n\n";
b1.showdata();
cout<<"\n\ndetails of book b2\n\n";
b2.showdata();
cout<<"\n\ndetails of book b3\n\n";
b3.showdata();

getch();
}

0 comments:

Post a Comment