class A{
int a;
public:
A(int i) {a=i;}
voidoperator()(const A & a )
{
this->a+=a.a+4;
}
const A operator+(const A& a)
{
return A(this->a +a.a);
}
const A& operator=(const A& a)
{
this->a =a.a;
return *this;
}
int diplaya(void){return a;};
};
void main( void )
{
A a(4);
A b(5);
A c(4);
a(a);
cout<<a.diplaya();
c=a+b;
c.diplaya();
int k;
cin>>k;
}
Well, let's see the version of the program that you have troubles with. If I add 'cout<<' in front of 'c.diplaya();' in your program, it works exactly as I would expect it to. It writes '12' followed by '17'.