【发布时间】:2014-01-01 22:17:03
【问题描述】:
我在我的代码中多次遇到这个问题(现在,我认为没有规避它):出于某种原因,当我尝试编写一个返回 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>
即使我有必要的课程#include'd。 这是为什么?这背后有什么理由吗??
这是一些模拟问题的代码:
#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
我试图编译它,它给了我上述错误....
【问题讨论】:
标签: c++ vector overloading complex-numbers