I have had this problem at numerous times in my code (and now, I think there is no circumventing it): For some reason, when I try to write a method that returns a std::vector<long double>
and try to overload it with the same method name that returns a different std::vector
, say, std::vector<std::complex<long double> >
, I get an error message akin to :
std::vector<std::vector<long double> > cannot be overloaded with std::vector<long double>
even though I the necessary classes #include'd. Why is this?? Is there any rationale behind this??
Here is some code simulating the problem:
#ifndef MATRIXALGORITHMS_H
#define MATRIXALGORITHMS_H
#include <complex>
#include <vector>
class MatrixAlgorithms
{
public:
MatrixAlgorithms();
//two algorithms that are not strictly for matrices; they are for solving quadratic and cubic polynomials
//quadratic method; the roots might be real, so there should be two versions of this algorithm
std::vector<long double> quadraticFormula(long double, long double, long double);
std::vector<std::complex<long double> > quadraticFormula(long double, long double, long double);
protected:
private:
};
#endif // MATRIXALGORITHMS_H
I tried to compile it and it gave me the aforementioned error....