Usage of properties/methods in derivative of template class

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

 



Found partially answer of my question 
http://gcc.gnu.org/ml/gcc-help/2006-10/msg00059.html there 
i.e. derivatives of template class should use this->x instead of x to be
able to get member x. The problem is that it seems related not only to x but
rather to all members of Der and it precedents i.e. in same example as in
link above:

template<class T>
class Base
{
protected:
    T x;
    Base() {}
    int DummyBase;
};

template <class T>
class Der: public Base<T>
{
public:
    using Base<T>::x; 

    Der():Base<T>() {}
    int get();
    void DoSmth();
    int DummyDer;
};

template <class T> void Der<T>::DoSmth()
{
    return DummyBase+DummyDer; // compiler shouts that both DummyDer and
DummyBase are out of scope.
} 


So, what's the reason for compiler to do so? What means "two pass
compilation of the templates" and why it leads to so unfavorable results? 
-- 
View this message in context: http://old.nabble.com/Usage-of-properties-methods-in-derivative-of-template-class-tp34061358p34061358.html
Sent from the gcc - Help mailing list archive at Nabble.com.



[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