我读过一些关于这个主题的帖子,但我不知道,使用对象指针的 stl 列表,当我想通过迭代器访问元素函数时,应用程序让我得到空指针的错误运行时间。有人会帮我吗?我很感激任何帮助。提前致谢。这是代码的一部分:
typedef std::list<Actor> listActors;
listActors listactors = pMain->Actors();
listActors::iterator iter = listactors.begin();
std::string nameactor;
nameactor = (*iter)->getName();//Here the app get a run time error of null pointer