Re: pure virtual functions and name injection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The two functions have different prototypes, I thought that the compiler was able to differentiate them. Different prototypes, but the same name. The name is what is causing the error, not the rest of the signature.

Ok, i guess this is because of the same name, but why is it ok with the C++ standard? operator++(int) and operator++() do have the same name, but they are considered as different by a c++ compiler...
Yes, but here it is a problem of visibility, not of resolving.

I think that the point is here :
It's a safety feature

so when calling a::foo() the compiler should redirect the call to the implementation d::foo(), no?
No, when you use the :: operator on a super-class, you explicitely ask not to use the "dynamic binding". Otherwise, it would be impossible to call the code of super-class
Take that simple example :

struct A
{
  virtual int f(void) {return 1;}
};

struct B : public A
{
virtual int f(void) {return A::f();} //fortunately, it does not call B::f(), or it would be indefinitely recursive
};

Pierre Chatelier

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux