有两个文件代码,一个aa.h,一个bb.h,如下:
//aa.h
#ifndef _AA_H_
#define _AA_H_
//#include"bb.h" //这行代码出问题
template<class T1,class T2>
T1 cvtType(T2 x)
{
}
#endif
//bb.h
#ifndef _BB_H_
#define _BB_H_
#include"aa.h"
template<class T>
void func(T x)
{
cvtType<std::string>(x);
}
#endif
如果加上include"bb.h"就会报错如下:

如果不加上就能编译成功。 虽然说删掉include"bb.h"就能解决问题,但是我还是想了解一下背后的原因。 已经加上了ifndef,为什么还是报错。 求解答。