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.

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

https://ideone.com/EmO1xy​

2. 要包含下面的头文件

#include <memory>

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

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;
}

C++ error: ‘shared_ptr’ was not declared in this scope_开发语言_02