C++ Programming Blog

 
 
 
 #include<iostream.h>
 #include<conio.h>


 //------------------------------  assign  -------------------------------//


 class assign
    {
       private:
        int day;
        int month;
        int year;

       public:
        assign() { day=1;month=1;year=2001; }
        assign(int d,int m,int y) { day=d; month=m; year=y; }
        void showdata();
    };



 //---------------------------  showdata( )  -----------------------------//


 void assign::showdata()
    {
       cout<<\"\\t\"<<day<<\'-\'<<month<<\'-\'<<year<<endl;
    }


 main( )
    {
       clrscr();

       assign date1;
       assign date2(14,8,1947);
       assign date3(date2);
       assign date4=date1;

       cout<<\"\\n Date1 is : \";
       date1.showdata();

       cout<<\"\\n Date2 is : \";
       date2.showdata();

       cout<<\"\\n Date3 is : \";
       date3.showdata();

       cout<<\"\\n Date4 is : \";
       date4.showdata();

       date2=date4;
       cout<<\"\\n After member wise copy date2 is : \";
       date2.showdata();

       getch();
       return 0;
    }