I have 4 files: header.h, header.cpp, header2.h and header2.cpp, like the ones below:
header.h
# pragma once
# include "header2.h"
template<class T>
class firstClass
{
T var;
public:
firstClass(T v){ var = v; }
void output(void){ cout << var << endl; }
};
header.cpp
// # include "header.h"
header2.h
# pragma once
# include "header.h"
class secondClass:public firstClass<char>
{
public:
secondClass(char a):firstClass(a){}
};
header2.cpp
# include "header2.h"
The problem happens if I un-comment the line in header.h, I got an error in code::blocks:
error in file(header2.h): expected template-name before '<' token
Is anyone know why the problem, and how to fix it. Thank you very much)