相当容易理解。这是导致“新向量”行出现SIGABRT的方法:
请注意,我在其他地方调用该准确行时没有任何问题。以下是Task类中包含的列表:
请注意,在其他地方我调用了那一行而没有任何问题。这是Task类中包含的包含列表:
有什么想法吗?
vector<string> * Task::arguments() {
vector<string> *args = new vector<string>(); // CAUSES SIGABRT
int count = sizeof(_arguments);
for (int x = 0; x < count; x++) {
string argument(_arguments[x]);
args->push_back(argument);
}
return args;
}
请注意,我在其他地方调用该准确行时没有任何问题。以下是Task类中包含的列表:
请注意,在其他地方我调用了那一行而没有任何问题。这是Task类中包含的包含列表:
#include <vector>
#include <unistd.h>
#include <string>
using namespace std;
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
有什么想法吗?
std::vector
?你几乎肯定应该使用一个局部变量并通过值返回它。 - James McNellisusing namespace std;
,请将它放在所有包含指令之后。 - Benjamin Lindley