class plugin {
public:
enum RunStatus {
Running = 0
};
int test()
{
printf("test null shared ptr\n");
return 0;
}
};
int main()
{
std::shared_ptr<plugin> iter = NULL;
std::cout << iter->test() << std::endl; // 不会异常退出
std::shared_ptr<int> iterInt = NULL;
std::cout << *iterInt << std::endl; // 异常退出
return 0;
}
如果plugin类有成员变量,也会异常退出