c++ - Accessing public members of base class fails -


A coward can be a little bit of a question: I have two classes, and all the variables are declared public. Why can not I use the variable from the derived class ??

G ++ tells me: vec3d.h: 76: 3: error: a "val" has not been declared in this area

  template & lt; Typename TYPE & gt; Square vec {public: TYPE * val; Int dimensions; Public: vec (); Vec (TYPE right); Vec (TYPE correct, int _dimension); [Etc] Template & lt; Typename TYPE & gt; Square vec3d: public vec & lt; TYPE & gt; {Public: vec3d (): vec & lt; TYPE & gt; (0, 3) {}; Vec3d (TYPE rights): vec & lt; TYPE & gt; (Right, 3) {}; Vec3d (TYPE X_val, TYPE Y_val, TYPE Z_val): vec & lt; TYPE & gt; (0, 3) {val [0] = X_val; //// & lt; ---------- This one failed! Val [1] = Y_val; Val [2] = Z_val; }; [Etc] 

This is purely a lookup issue and there is nothing to do with access control.

Because vec3d is a template and its base class depends on the template parameter, members of the base class do not automatically appear in the class generated in the expression, which is non-dependent. To use the basic expression for the simplest, such as this-> X_val .

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -