Tuesday, March 17, 2015

program to demonstrate the use of constant member functions? (C plusplus or C++)

Aim: Write a program to demonstrate the use of constant member functions?
Ans:
#include<conio.h>
#include<iostream.h>
class  constant
{
int a,b,c;
public:
       void input()
            {
                        a=10;
                        b=20;
                        c=30;
            }
             void const  output()
            {
                        cout<<"a="<<a<<"b="<<b<<"c="<<c;
                        //This member function cannot  modify the numbers
            }
}x;
void main()
{
            clrscr();
            x.input();
            x.output();
            getch();
}






No comments:

Post a Comment