J
Juha Tenhosaari
Hello,
I wonder if anyone could tell me why the operator= is not inherited into the
derived class in the following code:
class A
{
public:
void operator=(int i){a=i;}
int a;
}
class B : public A
{
public:
int b;
}
void main(void)
{
B bb;
bb=3; // trying to use the overloaded operator
cout << bb.a;
}
When I try to compile this, I get the error message "could not find match
for B:perator=(int)". If I replace the overloaded operator by an ordinary
function (i.e. operator=(int) => set(int)), it works fine.
What am I doing wrong?
Juha
I wonder if anyone could tell me why the operator= is not inherited into the
derived class in the following code:
class A
{
public:
void operator=(int i){a=i;}
int a;
}
class B : public A
{
public:
int b;
}
void main(void)
{
B bb;
bb=3; // trying to use the overloaded operator
cout << bb.a;
}
When I try to compile this, I get the error message "could not find match
for B:perator=(int)". If I replace the overloaded operator by an ordinary
function (i.e. operator=(int) => set(int)), it works fine.
What am I doing wrong?
Juha