Tuesday, 2 July 2013

Write a program to show the concept of Constant Member Function in C++

#include<iostream.h>
#include<conio.h>
class date
{
    int day;
     int month;
     int year;
     public:
     void getdata(int a , int b ,int c)//define function
     {
         day=a;
         month=b;
         year=c;
     }
     void display(void)const//define const function
     {
         cout<<"date is "<<day<<"-"<<month<<"-"<<year;
        cout<<"\n";
     }
};//end of class definition
void main()
{
    date birthday;
    birthday.getdata(15 ,11, 19);
    birthday.display();
}

No comments:

Post a Comment