1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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,287
    Likes Received:
    364
    Trophy Points:
    83
    Please just do not bump the threads.
     

Share This Page