simple template class inheritance

Discussion in 'C++' started by arkangel, Aug 26, 2008.

  1. arkangel

    arkangel New Member

    Joined:
    Aug 11, 2008
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    Code:
    template<class Z>
    class A1{
    protected :
    	Z  u;
    
    public:
    	A1(Z pu):u(pu){}
    	Z getU(){return u;}
    
    };
    
    
    template <class  Z>
    class A2:public A1<Z>{
    
    public:
    	A2(Z pu):A1<Z>(pu){};
    	Z nothing(){return u;}
    };
    
    

    In a normal class u is defined in this scope , but in a template is not . as protected shouldn't be visible within A2? what is wrong
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Please just do not bump the threads.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice