1.0.2 c++ inheritence pb
Thomas Kunert
kunert@physik.tu-dresden.de
Mon May 11 01:27:00 GMT 1998
Neal Becker wrote:
>
> Here is a simple example that I think shows a problem with egcs-1.0.2
> c++ inheritence.
>
> As shown it will not compile. o.Compute() does not resolve to the
> D::Compute(Complex* zin, Complex& zout). Why not?
>
> Here is what you get if you don't remove the comments:
>
> Bug.cc: In function `int main()':
> Bug.cc:32: no matching function for call to `O::Compute (complex<double>[8], complex<double> &)'
> Bug.cc:16: candidates are: O::Compute(complex<double> *, double &, double &)
>
> If you remove the comments, placing the identical declaration of
> Compute (Complex* zin, Complex& zout) in class O, now it compiles.
>
> ----------------------------
> #include <Complex.h>
>
> class D {
> public:
> virtual void Compute (Complex* zin, double& Iout, double& Qout);
>
> void Compute (Complex* zin, Complex& zout) {
> double Iout, Qout;
> Compute (zin, Iout, Qout);
> zout = Complex (Iout, Qout);
> }
> };
>
> class O : public D {
> public:
> virtual void Compute (Complex* zin, double& Iout, double& Qout);
> // void Compute (Complex* zin, Complex& zout) {
> // double Iout, Qout;
> // Compute (zin, Iout, Qout);
> // zout = Complex (Iout, Qout);
> // }
> };
>
> main () {
> O o;
>
> Complex DemodOut;
> const int SPS = 8;
> Complex RcvIn[SPS];
> o.Compute (RcvIn, DemodOut);
> }
> ---------------------
Hi Neal,
redeclaration fo 'Compute' in O doesn't overload but hides _all_
occurences of Compute in D. The Compiler is right.
You need to write
o.D::Compute (RcvIn, DemodOut);
Thomas Kunert
More information about the Gcc-bugs
mailing list