#include <memory>
#include <string>
#include <iostream> class Student {
public:
Student(std::string& name) {
_name = name;
}
~Student(){
} void printName(){
std::cout << _name << std::endl;
} private:
std::string _name;
}; int main() {
std::string name = "xiaowang";
std::unique_ptr<Student> p(new Student(name));
//Student p = Student(name);
//p.printName();
p->printName(); return ;
}
编译:默认g++3.4.5 报如下错误,unique_ptr是c++11的, g++3.4.5似乎也不支持这个。 main.cpp: In function 'int main()':
main.cpp::: error: 'unique_ptr' is not a member of 'std'
std::unique_ptr<Student> p(new Student(name));
^
main.cpp::: error: expected primary-expression before '>' token
std::unique_ptr<Student> p(new Student(name));
^
main.cpp::: error: 'p' was not declared in this scope
std::unique_ptr<Student> p(new Student(name)); 后经测试MM提示,改为用
/opt/compiler/gcc-4.8.2/bin/g++ -std=c++11 main.cpp (原来系统还藏了个高版本的,郁闷,干嘛不直接用高版本的啊) 编译无误。
^

c++ g++3.4.5 g++4.8.2 由编译器引起的编译异常的更多相关文章

  1. 【亲测】<g++/gcc>CentOS下g++: command not found问题的解决(c++环境安装)

    CentOS下g++: command not found问题的解决 2017年02月27日 18:09:06 阅读数:5174 标签: centosgcc 更多 个人分类: 问题分析   版权声明: ...

  2. link options and how g++ is invoked gcc g++

    yum install gcc yum install gcc-c++ yum reinstall gcc gcc-c++ Downloading packages:(1/2): gcc-c++-4. ...

  3. g++ -std=c++11 -g -o test emit_log_direct.cpp

    g++ -std=c++11 -g -o test  emit_log_direct.cpp

  4. linq 获取不重复数据,重复数据 var unique = arr.GroupBy(o => o).Where(g => g.Count() == 1) .Select(g => g.ElementAt(0));

    static void Main(string[] args) { int[] arr = { 1, 3, 3, 3, 3, 4, 5, 4, 5, 8, 9, 3 }; //不重复 var uniq ...

  5. sed初理多行合并+sed之G、H、g、h使用+sed n/N使用说明

    转载:[shell]sed处理多行合并 - seyjs - 博客园 (cnblogs.com) 文件格式 table=t1 name owner address table=t2 id text co ...

  6. Clang比 gcc/g++更人性化代码出错提示的C/C++编译器

    编译器方面的几个命令 gcc/g++ 一. 常用编译命令选项 常用用法 gcc -Wall test.c -o test gcc编译过程 .c ->(-E)-> .i[中间文件] -> ...

  7. 【转】25.windbg-!gle、g(错误码、g系列)

    !gle !gle 扩展显示当前线程的最后一个错误码.这个太好记了,getlasterror取首字母: <span style=:> !gle LastErrorValue: (Win32 ...

  8. CentOS 6.6 升级GCC G++ (当前最新版本为v6.1.0) (完整)

    ---恢复内容开始--- CentOS 6.6 升级GCC G++ (当前最新GCC/G++版本为v6.1.0) 没有便捷方式, yum update....   yum install 或者 添加y ...

  9. [翻译svg教程]svg 中的g元素

    svg 中的<g>元素用来组织svg元素.如果一组svg元素被g元素包裹了,你可以通过对g元素进行变换(transform),被g元素包裹的元素也将被变换,就好这些被svg包裹的元素是一个 ...

随机推荐

  1. Part 100 Func delegate in c#

    What is Func<T,TResult> in C#? In simple terms,Func<T,TResult> is just generic delegate. ...

  2. 在Windows Server 2012 中安装 .NET 3.5 Framework,PowerShell 安装.NET FRAMEWORK

    问题 如今,仍然有许多程序和应用需要依靠.NET 3.5 framework 来运行.在Windows Server 2012中,微软提供了.NET 3.5 和.NET 4.5的安装选项以为你的应用程 ...

  3. 运行第一个Node.js程序

    初学Node.js,萌新一枚.感觉Node.js挺不错的,从基础开始一步一步来,加油吧! 我们来使用Node.js的express来运行第一个程序helloworld: 在命令提示符键入express ...

  4. 《Cocos2d-x实战 C++卷》上线了-源码-样章-感谢大家的支持

    <Cocos2d-x实战 C++卷>上线了 感谢大家一直以来的支持! 全面介绍Cocos开发技巧,采用Cocos2d-x3.2版本,并且详细介绍跨平台移植已经多平台发布细节. · 各大商店 ...

  5. tslib 移植问题与解决方法

    问题一.执行脚本.提示出错,错误有"cann't exec aclocal" ,错误提示最多的是关于aclocal的问题,查资料显示这个文件是automake必备一个文件,好吧,那 ...

  6. 银联接口测试——详细(JAVA)

    准备材料 1.注册账号 https://open.unionpay.com/ajweb/register?locale=zh_CN 2.▼登录账号 -->帮助中心--> 下载,选择网关支付 ...

  7. 南阳理工ACM975--关于521

    http://acm.nyist.net/JudgeOnline/problem.php?pid=975 这是我的源码.一直超时,一直超时. 还有itoa函数函数的使用.可以改成sprintf(str ...

  8. 济南学习 Day 2 T2 pm

    她[问题描述]给你L,R,S,M,求满足L≤ (S × x) mod M ≤ R最小的正整数 X.[输入格式]第一行一个数T代表数据组数.接下来一行每行四个数代表该组数据的L,R,S,M.[输出格式] ...

  9. 简单工厂(Simple Pattern)模式

    一.简单工厂(Simple Factory)模式 Simple Factory 模式根据提供给它的数据,返回几个可能类中的一个类的实例.通常它返回的类都有一个公共的父类和公共的方法. Simple F ...

  10. 解决Eclipse中Java工程间循环引用而报错的问题

    如果myeclipse  报如下错误 A cycle was detected in the build path of project 如果我们的项目包含多个工程(project),而它们之间又是循 ...