出错代码如下:
//main.cpp
#include"aa.h"
int main()
{
return 0;
}
//aa.h
#ifndef _AA_H_
#define _AA_H_
#include"bb.h"
template<class>
struct is_sned{};
#endif
//bb.h
#ifndef _BB_H_
#define _BB_H_
#include"aa.h"
template<>
struct is_sned<int>{};
#endif
vs报错:
aa.h中包含了bb.h,而bb.h中又包含了aa.h,导致了循环嵌套。
修改方法:
把aa.h中的include "bb.h"删掉
如有帮助,望采纳,谢谢。
特化的模板,一定要和泛化的模板放在一起,因为全特化与偏特化是要有泛化的基础上才能声明的,且参数的数量与泛化的一致