W
web1110
Hi y'all,
I was playing with C++ and tried this program:
#include "stdafx.h"
#include <iostream.h>
class prop
{
private:
int x;
int y;
public:
prop(int x, int y);
int& X();
int& operator= (int);
};
prop:rop(int x, int y)
{
prop::x=x;
prop::y=y;
}
int& prop::X()
{
return x;
}
int& prop:perator=(int=0)
{
return x;
}
int main(int argc, char* argv[])
{
prop a(1, 2);
cout << "a.X=" << a.X() << '\n';
a.X=10; <-----------------------------------
cout << "a.X=" << a.X() << '\n';
return 0;
}
The marked line produces the error:
S:\tmp\VS60\Props\Props.cpp(39) : error C2659: '=' : overloaded function
as left operand
Can someone explain why?
Thanx,
Bill
I was playing with C++ and tried this program:
#include "stdafx.h"
#include <iostream.h>
class prop
{
private:
int x;
int y;
public:
prop(int x, int y);
int& X();
int& operator= (int);
};
prop:rop(int x, int y)
{
prop::x=x;
prop::y=y;
}
int& prop::X()
{
return x;
}
int& prop:perator=(int=0)
{
return x;
}
int main(int argc, char* argv[])
{
prop a(1, 2);
cout << "a.X=" << a.X() << '\n';
a.X=10; <-----------------------------------
cout << "a.X=" << a.X() << '\n';
return 0;
}
The marked line produces the error:
S:\tmp\VS60\Props\Props.cpp(39) : error C2659: '=' : overloaded function
as left operand
Can someone explain why?
Thanx,
Bill