这是我的代码:
#include <string>
#include <complex>
class a{
protected:
std::string name;
public:
a(std::string _name): name(_name) {};
virtual void inside(const complex<double> &b, const complex<double> &t) const = 0;
};
但是Visual Studio在我声明虚拟方法的行中给了我这些错误:
Error 1 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error 2 error C2143: syntax error : missing ',' before '<'
我看不出我做错了什么。
答案 0 :(得分:3)
与之前的std::string name;
类似,模板complex
已正确调用std::complex
答案 1 :(得分:2)
虽然它看起来不像错误,但这里错的是你错过了complex<double>
类型的命名空间规范。它也在std
命名空间中,因此您需要告诉编译器。尝试:
virtual void inside(const std::complex<double> &b, const std::complex<double> &t) const = 0;