> Tyler Earman <rem.intellegare@xxxxxxxxx> writes: > > >> I have a question regarding inheritance in C++ on GCC. Now I've asked >> this question in the past but I'd like to expound on it a little so we >> can have a less hackish approach to this system. I know GCC follows the >> C++98 standard very well and its the standard that's at fault for this >> little idiom, but I'd like to override it if possible. >> >> Basically when a class inherits another class, specifically with >> templates I believe, some of the methods within the first inherited >> class become unaccessible without the "this->" operator (or a "using" >> construct; the code is bellow). >> >> Now I know the better way of working this is to use multiple inheritance >> with virtual interfaces, but if possible I'd like to break the C++ >> standard right here for a moment, and enable GCC to compile the code >> without complaining about this particular ABI. >> >> Is there a way to do this? I don't think -fpermissive works, but would >> one of the older standards? >> > > There is no way to do this, and it would probably not be a good idea, > for exactly the reasons that the C++ standards committee designed > two-phase name lookup in the first place. > > Ian > Outside of the this-> operators, is there a better way of doing it? I've been working with virtual inheritance, by applying virtual interfaces, but this is also generating a large amount of errors (code bellow). #include <iostream> using namespace std; template <typename T> class Base { public: T *data; virtual ~Base() {delete [] data;} Base() {data = new T[100];} }; template <typename T> class A : public virtual Base<T> { protected: int alpha; }; template <typename T> class B: public virtual Base<T> { protected: T beta; }; template <typename T> class C: public virtual Base<T>, A<T>, B<T> { public: void f(T x) { data[0] = x ; cout << "\ndata[0] = " << data[0] << endl; } }; int main() { C<int> object; object.f(24); }