#include <stdio.h>
#include <stdlib.h>
class A
{
int a;
public:
A()
{
a=100;
}
int get()
{
return a;
}
};
int main()
{
A *a=new A();
int *p=(int *)a;
printf("%d\n",a->get());
*p=200;
printf("%d\n",a->get());
system("pause");
}
its out put is -
100
200
so can any body help me to avoid this situation bcoz as we can observ the class definition we can access the private members.