Similar to std::string name;
that you have earlier, the template complex
is properly called std::complex
Trying to write a pure virtual method but I apparently have the syntax wrong?
-
04-08-2022 - |
문제
Here's my code:
#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;
};
But visual studio is giving me these errors for the line where I have declared the virtual method:
Error 1 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error 2 error C2143: syntax error : missing ',' before '<'
I can't see what I'm doing wrong.
해결책
다른 팁
While it doesn't look like it from the errors, what's wrong here is that you've missed out the namespace specification on the type complex<double>
. It's also in the std
namespace, so you need to tell the compiler this. Try:
virtual void inside(const std::complex<double> &b, const std::complex<double> &t) const = 0;
제휴하지 않습니다 StackOverflow