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
Post a Comment