I am trying to create a generic circular buffer pattern, but there is some syntax error that I cannot understand. There is an error in my constructor, although it seems that I also parameterize the destructor and that it works. I followed the example in Stroustrup C ++, and it uses a parameter in front of the scope resolution operator, as well as in the function name, just like mine. I am also sure that there are no circular dependencies, because I only compile one file. In addition, the implementation and declarations are in the same file (CircBuf.h) and there is no corresponding .cpp file, so the link should not be a problem either. I tried to add the keyword "inline" according to this solution, and I get the same error.
template<typename T> class CircBuf {
CircBuf();
int size;
T *data;
public:
CircBuf(int);
~CircBuf();
};
template<typename T> CircBuff<T>::CircBuf<T>(int i) {
data = new T[i];
}
template<typename T> CircBuf<T>::~CircBuf<T>() {
delete data;
}
Makefile
all:
g++ -g -pedantic CircBuf.h -o prog
CircBuf.h:13:22: error: ‘CircBuff’ does not name a type