C++ shared_ptr 编译 error ‘shared_ptr’ was not declared in this scope修复
来源:互联网 发布:京东返利网站源码 编辑:程序博客网 时间:2024/06/05 16:30
#include<iostream>#include<cstring>#include<string>#include<memory>using namespace std;class Simple{ public: Simple(int p = 0) { number = p; std::cout << "Simple::" << number << std::endl; } ~Simple() { std::cout << "~Simple::" << number << std::endl; } void PrintSomething() { std::cout << "PrintSomething:" << info_extend.c_str() << std::endl; } std::string info_extend; int number;};void TestSharedPtr(){ std::shared_ptr<Simple> my_memory(new Simple(1)); if(my_memory.get()) { my_memory->PrintSomething(); my_memory.get()->info_extend = "Additon"; my_memory->PrintSomething(); (*my_memory).info_extend += "other"; my_memory->PrintSomething(); }}int main(){ TestSharedPtr(); return 0;}
编译:g++ -std=c++11 -o test.exe ptr.cpp
[jingsia@localhost ~]$ ./test.exe Simple::1PrintSomething:PrintSomething:AdditonPrintSomething:Additonother~Simple::1
0 0
- C++ shared_ptr 编译 error ‘shared_ptr’ was not declared in this scope修复
- Code::Block 'shared_ptr' was not declared in this scope
- error: '_localtime_not_threadsafe_' was not declared in this scope
- error: ‘exit’ was not declared in this scope
- error: `cout' was not declared in this scope
- error: 'UINT64_C' was not declared in this scope
- error: 'memcpy' was not declared in this scope
- error: 'memcpy' was not declared in this scope的解决
- error: ‘BYTE’ was not declared in this scope
- error: ‘closesocket’ was not declared in this scope
- error:inet_addr() was not declared in this scope
- error: ‘exit’ was not declared in this scope 的解决方法
- 关于error: ‘htons’ was not declared in this scope
- error: ‘memcpy’ was not declared in this scope 解决
- error: ‘alarm’ was not declared in this scope 解决
- error: ‘ostream_iterator’ was not declared in this scope
- error: 'glGenFramebuffersOES' was not declared in this scope
- error: 'LOGE' was not declared in this scope
- ELK多种架构及优劣
- echarts去掉垂直网格线
- EasyPusher实现将asterisk直播流以RTSP转发实现通话直播与录像
- 编译链接蘑菇街开源iOS SDK(TeamTalk)遇到的问题及解决方法
- sql基本用法
- C++ shared_ptr 编译 error ‘shared_ptr’ was not declared in this scope修复
- selenium+testng+gitblit+jenkins+ant自动化测试系列五:eclipse新建GIT仓库以及常用操作
- 图解phpstorm常用快捷键
- JAVA通过XPath解析XML性能比较
- sql中like的用法
- java判断scanner输入是中文、英文字母、数字还是特殊字符
- C#对加密算法的一些心得 DES、MD5、RSA
- bing-img
- 系统学习深度学习(九)--激活函数总结