C++ error C2143: 语法错误,缺少“;“(在”<“的前面)

编译时遇到一个错误,提示 error C2143: 语法错误,缺少";"(在”<"的前面)。
代码情况如下:

//Point.h
template<typename T>
namespace pp{
    
    
	class Point
	{
    
    
	public:
		T a;
	};
}
//Joint.h
#include "Point.h"
class Joint
{
    
    
public:
	Point<double> point;
};

折腾一会后发现是Point没有加命名空间,而error C2143: 语法错误,缺少";"(在”<"的前面),表达的意思是不知道<"前面是什么。所以遇到**这个错误的解决思路是查看报错行是否有未定义的类型**。
我这里的修改是在Joint.h里把Point的命名空间加上,如下

//Joint.h
#include "Point.h"
class Joint
{
    
    
public:
	pp::Point<double> point;
};

猜你喜欢

转载自blog.csdn.net/qq_40541268/article/details/129216604