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

Comments

Popular posts from this blog

Write a program to add two number using inline function in C++?

Traversing of elements program with algorithm and Flowchart