#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. hexo搭建静态博客

    1. 环境环境 1.1 安装Git 请参考[1] 1.2 安装node.js 下载:http://nodejs.org/download/ 可以下载 node-v0.10.33-x64.msi 安装时 ...

  2. JAVA:类,对象,成员属性,成员方法,构造方法,类变量,类方法<2>

    一.类的定义 一个全面的类定义是比较复杂的,  定义如下:

  3. (转)Yale CAS + .net Client 实现 SSO(4)

    第一部分:安装配置 Tomcat 第二部分:安装配置 CAS 第三部分:实现 ASP.NET WebForm Client 第四部分:实现基于数据库的身份验证 1.下载 Microsoft JDBC ...

  4. JS获取非行间样式及兼容问题

    获取非行间样式: <!DOCTYPE html> <html lang="en"> <head> <meta charset=" ...

  5. 基于 ArcGIS Silverlight API开发的WebGIS应用程序的部署

    部署流程概述 在微软的iis服务器上部署基于ArcGIS  Silverlight API的应用程序,主要包括以下几个步骤: 1)(可选)部署GIS服务 如果需要将GIS服务也部署在Web服务器上,则 ...

  6. 走出 null 就是空值的误区,以及变量赋值原理

    先放一张图片作为引入: 这里我用了一个示意图作为讲解: 平时,我们写的变量为什么能在我们调用它的时候就能被我们拿到所用,跟存钱罐一样,你往里面存一元大洋,它里面就有一元大洋,那么我们的变量在被我们创建 ...

  7. AndroidStudio支持新的NDK的操作使用

    在2015的Google I / O大会,5月底,谷歌宣布了一项新的支持由Android NDK Studio 1.3,Jetbrains CLion集成功能,Android gradle插件.这种支 ...

  8. CSS3实现半像素边框

    一.思路 普通的1px黑色实线边框: border: 1px solid #000; 半像素边框当然不是简单地把1px改为0.5px(没测试过,可能会被解析成1或者0),border-width的值只 ...

  9. Ubuntu 在未知root密码的情况下修改root密码

    一, 开机按 F12 (或长按Shift), 进入GRUB界面. 二, 在 recovery mode 按e Ubuntu, Linux 3.5.0-17-generic (恢复模式) (或recov ...

  10. (三)开始在OJ上添加签到功能

    在了解完OJ文件下的各个文件夹的主要作用后,我们开始往里面添加东西(其实只要知道各文件夹是干什么的后,添加东西也变得非常简单了) 一 在数据库中添加对应功能的字段. 我们这个学期才刚开数据库这门课,所 ...