can not find the class member in the base class

Dear friends:
I write a templates code , but i met the following error when compiled with g++4.8.5

vector.h:72:16: error: 'sze' was not declared in this scope
{ return sze ;}


It seems the class Vector can not find the class member sze in the base class. Could you give me some suggestions

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

template<class T> class BasicArray
{
public:
  int n() const 
    { return sze; } 
  BasicArray();

protected:
  int sze; 
  T *x;   
};


template<class T> class Vector : public BasicArray<T>
  {
  public:
    int rows() const //!< a reference to the size of the vector
      { return sze ;}
    Vector() : BasicArray<T>(1) {} //!< Basic constructor
    
    virtual ~Vector() {}
}
Last edited on

https://ece.uwaterloo.ca/~dwharder/aads/Tutorial/2z/

Program 3 in that link shows your problem.

Programs 4, 5 and 6 give solutions,
Topic archived. No new replies allowed.