Write a program to perform the concept of constant function in C++?



#include<iostream.h>
#include<conio.h>
class one
{
public:
int i;
public:
void show() const
{
i=2;
cout<<"i is "<<i;
}
void show()
{
i=5;
cout<<"i is "<<i;
}
};
void main()
{
class one obj;
obj.show();
getch();
}
 




ERROR:-

cannot modify a const object
 

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