C++ error: ‘shared_ptr’ was not declared in this scope

1. 要使用C++ 11以上版本

在线的C++编辑器EmO1xy - Online C++0x Compiler & Debugging Tool - Ideone.comCompile various programming languages online. Add input stream, save output, add notes and tags.https://ideone.com/EmO1xy

2. 要包含下面的头文件

#include <memory>

error: ‘shared_ptr‘ was not declared in this scope_追梦-北极星的博客-CSDN博客

3. 测试代码

#include <iostream>
#include <memory>
using namespace std;

int main() {
	// your code goes here
	cout<<"999999";
	shared_ptr<int> sp1(new int(100));
	cout<<"sp1的值: "<<*sp1<<endl;
	return 0;
}

猜你喜欢

转载自blog.csdn.net/u013288190/article/details/127175190
今日推荐