This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Template inheritance


On 28 June 2012 11:20, icegood <icegood1980@gmail.com> wrote:
>
> #include <cstddef>
> #include <new>
> #include <iostream>
> #include <cstdlib>
>
> class Base
> {
> public:
> ?Base(){FBase=123;}
> protected:
> ?int FBase;
> };
>
> template<typename T>
> class A : public Base
> {
> public:
> ?A(){}
> ?T FA;
> };
>
> template<typename T>
> class B : public A<T>
> {
> public:
> ?B(){}
> ?T FB;
> ?virtual void F() {std::cout <<FBase << std::endl;} // fails here
> ?inline void SetB(int vB) {FB=vB;}
> };
>
> int main()
> {
> ?B<int> VB;
> ?//
> ?VB.F();
> }
>
> - doesn't compile. A<T>::FBase ?instead of FBase solves isuue. Could it be

This is how C++ works, see
http://gcc.gnu.org/wiki/VerboseDiagnostics#dependent_base

> somehow easier, because have
> ~100 properties in Base class each of them called 100 times in B.

You could write this->FBase instead.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]