Re: Template inheritance

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

 



On 28 June 2012 11:20, icegood <icegood1980@xxxxxxxxx> 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 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