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();
}

Related Posts:

  • inheritance in c++ part2 //accessing base less constructer #include<iostream.h> #include<conio.h> class parent              /… Read More
  • friend class in c++ #include<iostream.h> #include<conio.h> //class B;   here class b declaration is not necessary b/c in class A,      … Read More
  • inheritance in c++ #include<iostream.h> #include<conio.h> class more1           //base/super/parent class { protected: int posit… Read More
  • Accessibility in c++ //check the accessability of static and non static variables/functions #include<iostream.h> #include<conio.h> class test { private: sta… Read More
  • operator overloading in c++ #include<iostream.h> #include<conio.h> //THE OPERATORS {DOT OPERATOR (.), SCOPE RESOLUTION OPERATOR(::), CONDITIONAL OPERATOR(?:), POINT… Read More

0 comments:

Post a Comment