class.h
// class.h
#pragma once
#include <string>
#include <iostream>
class TV {
public:
TV() {}
TV(std::string, std::string, std::string, std::string, std::string);
private:
int member;
};
main.cpp中:
//main.cpp
#include "class.h"
TV::TV(std::string a, std::string b, std::string c, std::string d, std::string e) {
try {
member = std::stol(a);
if (member <= 0)
throw;
}
catch (...) {
std::cout << "Invalid argument" << std::endl;
}
}
int main(int argc, char *argv[]) {
new TV("TEST","NAME","0.1","0.1","0.1");
};
事实证明,如果我为std :: stol提供了invalid_argument,那么在gdb中传递给该函数的所有其他参数都会显示为已损坏。
有人可以解释为什么会这样吗?