error: expected template-name before ‘<’ token

Hello: I am writing a derived class, where I have to specify a virtual member function of the base class. The definitions of the member functions of the derived class are in a cpp file.
The code for the Derived class in the header file:
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
32
33
34
35
36
37
#ifndef MC__MSetINV_H
#define MC__MSETINV_H

#include "setinv.h"     // SetInv is the base class


template <typename T>
class mSetInv: public SetInv<T>
{

 public:

   //Constructor
   mSetInv():  _nt(0), _P_m(0),NTE(4) {};

   // Default Destructor
   ~mSetInv() { delete _P_m;} 

   // Define the set to be inverted, including the error
   void inverted_set
      (const unsigned int nt, const T*P);

   //User-function to subproblem assessment
   typename SetInv<T>::STATUS assess
     ( const unsigned int np, T*P );

 private:
   // number of measurements
   unsigned int _nt;
   // Y set including the error
   T *_P_m;
   // Chebychev expansion order
   unsigned int NTE;

};

#endif 

The error is the last public member function which is the defined virtual class. The base class is 12 pages long but it has a member of type enum and named STATUS.

The relevant part of the main.cpp file :
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <iostream>
#include "cmodel.hpp"
#include "mSetInv.h"

#ifdef USE_PROFIL
  #include "mcprofil.hpp"
  typedef INTERVAL I;
#else
  #ifdef USE_FILIB
    #include "mcfilib.hpp"
    typedef filib::interval<double> I;
  #else
    #include "interval.hpp"
    typedef mc::Interval I;
  #endif
#endif

typedef mc::CModel<I> CM;
typedef mc::CVar<I> CV;



// Definition of the functions in the class
template <typename T>
inline void mSetInv<T>::inverted_set
( const unsigned int nt, const T*P)
{
   _nt = nt;
   _P_m = new T[_nt];
   for (unsigned int i=0; i<_nt;i++) _P_m[i] = P[i];
}

template <typename T>
inline typename SetInv<T>::STATUS 
mSetInv<T>::assess ( const unsigned int np, T*P )
{ 
  SetInV<T>::STATUS status; 
  // Enclosure of the model fct using Chebychev bounding
     CM mod (np,NTE);  // np: # of state variables
     CV* CVx= new CV[np];
     CV* CVF= new CV[_nt];
     T bounding [_nt];
     for (unsigned int i=0;i<np;i++) 
       CVx[i].set(&mod,i,P[i]);
     CVF = model_function (CVx,CVF);
     for (unsigned int i=0;i<_nt;i++)
        bounding [i] = CVF[i].B();
  // inclusion tests
     bool flag = true;
     T P_inter ; // Just for the purpose of the inter operator
     for (unsigned int i=0;i<_nt;i++){
       if ( Op<T>::l(bounding[i]) > Op<T>::u(P[i]) || Op<T>::u(bounding[i]) < Op<T>::l(P[i]) ) { // no intersection
             delete []CVx;
             delete []CVF;             
             return SetInV::OUTER;
        }
       if ( Op<T>::l(bounding[i]) < Op<T>::l(P[i]) || Op<T>::u(bounding[i]) > Op<T>::u(P[i]) )
              flag =false;
     }
    delete []CVx;
    delete []CVF;
    return (flag?  SetInv<T>::INNER : SetInv::UNDERTERMINED);
}


I really appreciate your help and time.
Please copy and paste the entire error and specify exactly which line number it occurs on.
the error is around line 37
Last edited on
Please copy and paste the exact error and specify exactly which line number it occurs on.
SetInV is not the same as SetInv. You'll also need to put typename in front of the type.
helios, I did not get what did you mean by put typename infront of the type; the keyword typename is there.
The detailed error:

In file included from main.cpp:16:0:
mSetInv.h:11:29: error: expected template-name before ‘<’ token
mSetInv.h:11:29: error: expected ‘{’ before ‘<’ token
mSetInv.h:11:29: error: expected unqualified-id before ‘<’ token
main.cpp:78:35: error: invalid use of incomplete type ‘class mSetInv<T>’
mSetInv.h:11:7: error: declaration of ‘class mSetInv<T>’
main.cpp:87:49: error: invalid use of incomplete type ‘class mSetInv<T>’
mSetInv.h:11:7: error: declaration of ‘class mSetInv<T>’
make: *** [main.o] Error 1
The error is in this line:
1
2
typename SetInv<T>::STATUS assess
     ( const unsigned int np, T*P );
This is no use. I need to be able to match the error message to the line in question. Either post the entire code, or correct the line numbers on the error messages.
http://www.eelis.net/iso-c++/testcase.xhtml
Make sure any line numbers you mention in the testcase are correct


Make sure your testcase is self-contained and actually reproduces the problem
1
2
3
4
5
6
7
8
9
10
11
template<class T>
class foo{
public:
	enum asdf{};
};

template<class T>
class bar: public foo<T>{
public:
	typename foo<T>::asdf qwerty();
};
compiles


> the error is around line 37
>> SetInV is not the same as SetInv. You'll also need to put typename in front of the type.
>>> helios, I did not get what did you mean
look at line 37
Last edited on
sorry helious for the inconsistency, the modified error message:

mSetInv.h:8:29: error: expected template-name before ‘<’ token
mSetInv.h:8:29: error: expected ‘{’ before ‘<’ token
mSetInv.h:8:29: error: expected unqualified-id before ‘<’ token

I do not know what is wrong in the declaration of the class mSetInv
Topic archived. No new replies allowed.