N
nw
Hi comp.lang.c++,
I have the following header (simple.h):
#ifndef SIMPLE
#define SIMPLE
template<class _prec=double>
class Simple {
public:
Simple() {
}
Simple<_prec> next;
};
#endif
and c++ file:
#include <iostream>
#include "simple.h"
using namespace std;
int main() {
Simple<double> s;
}
Compilation gives me the error:
simple.h: In instantiation of 'Simple<double>':
simple.cpp:7: instantiated from here
simple.h:12: error: 'Simple<_prec>::next' has incomplete type
simple.h:5: error: declaration of 'class Simple<double>'
under g++ 4.1.2. I guess I need to add a prototype for Simple, but I
can't quite see how to do this for a template class. Any help
appreciated!
I have the following header (simple.h):
#ifndef SIMPLE
#define SIMPLE
template<class _prec=double>
class Simple {
public:
Simple() {
}
Simple<_prec> next;
};
#endif
and c++ file:
#include <iostream>
#include "simple.h"
using namespace std;
int main() {
Simple<double> s;
}
Compilation gives me the error:
simple.h: In instantiation of 'Simple<double>':
simple.cpp:7: instantiated from here
simple.h:12: error: 'Simple<_prec>::next' has incomplete type
simple.h:5: error: declaration of 'class Simple<double>'
under g++ 4.1.2. I guess I need to add a prototype for Simple, but I
can't quite see how to do this for a template class. Any help
appreciated!