neath@solar-1.stars.flab.Fujitsu.JUNET (04/28/89)
The following code causes an internal error and bus error in cfront version
1.2.1 when I try to compile it. I believe that this is valid, although somewhat
unusual, C++ syntax. Is this acceptable code? This initialization works fine if
I change private data slot 'a' from a class_b& to something like an int.
---------------------------- Cut Here -----------------------------
#include "stream.h"
class class_b {
int b;
public:
class_b(int&);
void print();
};
class class_a {
class_b& a;
public:
class_a(class_b&);
};
class_a::class_a(class_b& tb) : a(tb) {
a.print();
}
class_b::class_b(int& i) {
b = i;
}
void class_b::print() {
cout << "This is output from class_b : b = " << b;
}
main() {
class_b B(10);
class_a A(B); // This initializer should print 10 from B
}
---------------------------- Cut Here -----------------------------
Regards
Martin Neath <neath@dsg.ti.com>
------------------------------------------------------------------------
DISCLAIMER: As always, the opinions expressed above are strictly my own
and do not reflect those of my employer, Texas Instruments.
------------------------------------------------------------------------
--
Regards,
Martinark@alice.UUCP (Andrew Koenig) (04/30/89)
In article <NEATH.89Apr28070320@solar-1.stars.flab.Fujitsu.JUNET>, neath@solar-1.stars.flab.Fujitsu.JUNET writes: > The following code causes an internal error and bus error in cfront version > 1.2.1 when I try to compile it. I believe that this is valid, although somewhat > unusual, C++ syntax. Is this acceptable code? This initialization works fine if > I change private data slot 'a' from a class_b& to something like an int. < code omitted > Your example is indeed valid C++. It works fine on the (pre-release) cfront 2.0 running here. -- --Andrew Koenig ark@europa.att.com