<分区>
我在我的代码中多次遇到这个问题(现在,我认为没有办法绕过它):出于某种原因,当我尝试编写一个返回 std::vector<long double>
的方法时并尝试使用返回不同 std::vector
的相同方法名称重载它,比如说,std::vector<std::complex<long double> >
,我收到类似于以下内容的错误消息:
std::vector<std::vector<long double> > cannot be overloaded with std::vector<long double>
即使我有必要的类(class)#include'。 这是为什么??这背后有什么道理吗??
下面是一些模拟问题的代码:
#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
我试图编译它,但它给了我上述错误....