Template inheritance problem.

This error apparently makes no sense. Check the code, the error is marked.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
template <class KEY>
class PrimaryIndex {
  protected:
    int nEntries; 
  public:
    // methods
};


template <class KEY>
class SimpleRAMIndex : public PrimaryIndex<KEY>{ 
   private:
      PrimaryIndexEntry<KEY> Tabla[SRI_SIZE];
      int pos;
      bool BinarySearch(const KEY& k){
         int ini(0), fin (nEntries-1); //nEntries undeclared. What the hell?
         while (ini <= fin){
            pos = ((ini+fin)/2);
            if (Tabla[pos].key == k)
               return true;
            else if (tabla[pos].key < k)
               ini = pos+1;
            else
               fin = pos-1;
         }
         pos = ini;
         return false;
      }
   public:
      //methods
};


thanks in advance
Last edited on
looks fine, how are you using the code?
Try to replace nEntries with this->nEntries and see if that works
This could possibly be a GCC compiler thing.
GCC would give that error, MSVC won't.
Try using the base class scope resolution:


int ini(0), fin (PrimaryIndex<KEY>::nEntries-1)
Last edited on
Last edited on
Thanks a lot!
Also, thanks for the links, Disch.
Topic archived. No new replies allowed.