我有一个具有以下虚函数的类
namespace Book
{
class Secure
{
virtual Result setPassword(const std::map<std::string, std::vector<std::string> >& params)=0;
}
}
我还有另一个测试类,其中一个方法从excel获取密码和用户名,并将其设置为map secureParams并设置当前文件的密码。
bool initialize(std::string bookPath, std::string loginPath, std::string userName, std::string password)
{
Book::SharedPtr<Book::Secure> secure;
bool result;
std::map<std::string, std::vector<std::string> > secureParams;
std::vector<std::string> userNames;
std::vector<std::string> passwords;
userNames.push_back(userName);
passwords.push_back(password);
secureParams.insert(std::pair<std::string, std::vector<std::string>>("USERNAME",userNames);
secureParams.insert(std::pair<std::string, std::vector<std::string>>("PASSWORD",passwords);
secure->setPassword(secureParams);
secure->getLoginFile(loginPath.c_str());
result=Book::SecureBook::canLogin(bookPath.c_str(),secure);
return result;
}
运行时代码终止,提示未知文件:失败测试体内引发了未知的C ++异常。
在XCode中调试时,它在secure-> setPassword(secureParams)行中显示EXC_BAD_ACCESS(code = 1,address = 0xc0000000)错误]]
我整天都在尝试调试问题。任何帮助表示赞赏:)
提前感谢:)
我有一个具有以下虚拟函数名称空间的类Book {类Secure {虚拟结果setPassword(const std :: map <:string std::vector>>&params)= 0; } ...
您似乎没有从Book :: Secure继承的对象,它只是指向抽象基类的智能指针。当取消引用从未设置为指向实际对象的智能指针时,会发生崩溃。
您解决了问题吗?我被类似的事情困住了!