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 - |
Frage
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.
Lösung
Andere Tipps
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;
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow