我在以下代码中遇到运行时崩溃并且也无法调试。请查看并让我知道发生了什么。
// CppConsole.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <assert.h>
class Test : public std::tr1::enable_shared_from_this<Test>
{
public:
Test():x(0),y(0),z(0){};
int x;
float y;
double z;
};
int _tmain(int argc, _TCHAR* argv[])
{
std::tr1::shared_ptr<Test> t1(new Test);
std::tr1::shared_ptr<Test> t2 = t1->shared_from_this();
return 0;
}
我已经包含了所有标题,并且程序编译正常。这是我得到的错误:
CppConsole.exe - 未找到入口点 程序入口点 ?_Xweak@tr1@std@@YAXXZ 无法在动态链接库 MSVCP90D.dll 中找到
如果我注释掉这一行
std::tr1::shared_ptr t2 = t1->shared_from_this();
该程序运行而不会崩溃。
更新:问题可以暂时关闭。我将尝试安装 VS 功能包并查看程序执行时没有任何崩溃的天气。