我写下面的代码
#include <vector>
#include <cmath>
#include <cfloat>
#include <iostream>
#include <algorithm>
using namespace std;
vector< vector<double> > merge_sort(vector< vector<double> >& source, vector< vector<double> >& result){
}
int main(){
vector < vector<double> >test;
vector < vector<double> >temp;
merge_sort(test, temp);
}
Run Code Online (Sandbox Code Playgroud)
而我的例外,该程序关闭,我只是得到错误的分配预算,我不知道为什么,我甚至没有访问任何元素.
请告诉我如何解决它.
Thx提前.
你的问题是你的函数有一个返回类型,但你没有返回任何东西.这为您提供了未定义的行为.见§6.6.3:
流出函数的末尾相当于
return没有值; 这会导致值返回函数中的未定义行为.