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:
#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
(constunsignedint nt, const T*P);
//User-function to subproblem assessment
typename SetInv<T>::STATUS assess
( constunsignedint np, T*P );
private:
// number of measurements
unsignedint _nt;
// Y set including the error
T *_P_m;
// Chebychev expansion order
unsignedint 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.
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
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.
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