gjditchfield@violet.UUCP (10/19/87)
I think this is a bug, but it may be that I don't understand the
interaction of inheritance and operators.
----------------------------------------------------------------
class base {
int i;
public:
base() {i = 10;};
int operator=( int ip) { int t = i; i = ip; return t;};
};
class derived: public base {
float f;
public:
derived():() {};
};
#include <stream.h>
main () {
base b;
derived d;
cout << ( b=(5) );
cout << b.operator=(4);
cout << d.operator=(15);
cout << ( d=(16) ); // line 22
};
------------------------------------------------------------
ccc dervEq.cc:
"dervEq.cc", line 22: error: assignment not defined for class derived
"dervEq.cc", line 22: error: pointer operand for <<
If "a = b" and "a.operator=(b)" are equivalent (lines 18, 19), and if
derived did inherited "operator=" (line 21), why doesn't line 22 work?
Oh, yes: C++ version 1.2.1, BSD 4.3 on a vax. The same for my previous
posting, "Bug?"
--
Glen Ditchfield {watmath,utzoo,ihnp4}!watrose!gjditchfield
Dept of Computer Science, U of Waterloo (519) 885-1211 x6658
Waterloo, Ontario, Canada Office: MC 2006
If you grab the bull by the horns, you at least confuse him -- R.A.Heinlein