#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. .Net 接连 Oracle 数据库(Winform)

    之前一直是使用Asp.Net 连接 Oracle 10g,最近想写个小程序,所以选择了 Winform.折腾半天后,才发现 Winform 与 Asp.Net 连接 Oracle 是有些许区别的. 区 ...

  2. 20150226--WebForm中GridView

    WebForm中的GridView的用法基本与winForm中的DataGridView一致, 其数据绑定的方法使用LinqDateSource 将GridView拖拽进网页中,出现以下格式: 自动套 ...

  3. hdu 1963 Investment 多重背包

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1963 //多重背包 #include <cstdio> #include <cstr ...

  4. android 数据库中的事务_银行转账示例

    主java package com.itheima.transtation; import com.itheima.transtation.db.BankOpenHelper; import andr ...

  5. 《C++Primer中文版》读书笔记——第1章 开始

    istream对象:cin(标准输入对象); ostream对象:cout(标准输出对象) cerr(输出错误和警告) clog(输出一般性信息) 读取数量不定的输入数据,eg , sum=; whi ...

  6. TCP通信三次握手的过程

    过程 编辑 第一次 第一次握手:建立连接时,客户端 发送syn包(syn=j)到服务器,并进入SYN_SENT状态,等待服务器确认:SYN:同步序列编号(Synchronize Sequence Nu ...

  7. bzoj 1132 POI2008 Tro

    大水题=_=,可我想复杂了…… 很裸的暴力,就是加了个小优化…… 叉积求面积 :abs(xi*yj - yi*xj) 所以去掉绝对值,把 xi 和 xj 提出来就可以求和了 去绝对值加个极角排序,每次 ...

  8. Apache+lvs高可用+keepalive(主从+双主模型)

    Apache+lvs高可用+keepalive(主从+双主模型)     keepalive实验准备环境: httpd-2.2.15-39.el6.centos.x86_64 keepalived-1 ...

  9. 比较不错的JS 曲线图

    fashion chart   falsh文件支持,无需考虑兼容 Highcharts(纯JS,很漂亮 效果很好) Highcharts是一个制作图表的纯Javascript类库,主要特性如下: 兼容 ...

  10. jQuery实现分页

    转载地址 http://www.cnblogs.com/xiaoruoen/archive/2012/01/11/2318199.html ;( function($){ $.extend({ &qu ...