Question

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.

Was it helpful?

Solution

Similar to std::string name; that you have earlier, the template complex is properly called std::complex

OTHER TIPS

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;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top