Simple Class Program in C++


/* a program to assign data to the data members
of  class such  as day , month, year and
 to display the contents of the class on the sreen*/

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


class date
{
       private :
        int day ;
        int month;
        int year;
        public:
        void getdata(void)
        {
            cout<<"enter the data(dd-mm-yy)"<<endl;
          cin>>day>>month>>year;
        }
       
        void display(void)
          {
              cout<<"today's date is ="<<day<<"/";
              cout<<month<<"/"<< year<<endl;
      }
            };
        void main(void)
     {
         class date today ;
         today.getdata() ;
         today.display();
       }

No comments:

Post a Comment

Custom Search