c++ g++3.4.5 g++4.8.2 由编译器引起的编译异常
#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 由编译器引起的编译异常的更多相关文章
- 【亲测】<g++/gcc>CentOS下g++: command not found问题的解决(c++环境安装)
CentOS下g++: command not found问题的解决 2017年02月27日 18:09:06 阅读数:5174 标签: centosgcc 更多 个人分类: 问题分析 版权声明: ...
- 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. ...
- g++ -std=c++11 -g -o test emit_log_direct.cpp
g++ -std=c++11 -g -o test emit_log_direct.cpp
- 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 ...
- sed初理多行合并+sed之G、H、g、h使用+sed n/N使用说明
转载:[shell]sed处理多行合并 - seyjs - 博客园 (cnblogs.com) 文件格式 table=t1 name owner address table=t2 id text co ...
- Clang比 gcc/g++更人性化代码出错提示的C/C++编译器
编译器方面的几个命令 gcc/g++ 一. 常用编译命令选项 常用用法 gcc -Wall test.c -o test gcc编译过程 .c ->(-E)-> .i[中间文件] -> ...
- 【转】25.windbg-!gle、g(错误码、g系列)
!gle !gle 扩展显示当前线程的最后一个错误码.这个太好记了,getlasterror取首字母: <span style=:> !gle LastErrorValue: (Win32 ...
- CentOS 6.6 升级GCC G++ (当前最新版本为v6.1.0) (完整)
---恢复内容开始--- CentOS 6.6 升级GCC G++ (当前最新GCC/G++版本为v6.1.0) 没有便捷方式, yum update.... yum install 或者 添加y ...
- [翻译svg教程]svg 中的g元素
svg 中的<g>元素用来组织svg元素.如果一组svg元素被g元素包裹了,你可以通过对g元素进行变换(transform),被g元素包裹的元素也将被变换,就好这些被svg包裹的元素是一个 ...
随机推荐
- Android 动画学习笔记
Android动画的两种:Frame帧动画.Tween动画(位移动画)[实现:存放目录res/anim] Tween动画:(位移.缩放.旋转):通过对场景里的对象不断做图像变换. 四种效果Alpha. ...
- Cocos2d-JS中瓦片地图API
为了访问瓦片地图,Cocos2d-JS中访问瓦片地图API,主要的类有:TMXTiledMap.TMXLayer和TMXObjectGroup等.1.TMXTiledMapTMXTiledMap是瓦片 ...
- Xcode中使用插件
有两种添加插件的方法.推荐第二种 一.就是在Github上找到你要安装的插件,然后在Xcode完全退出后,打开你要安装的插件,编译就行了,然后完全退出后,重新打开Xcode,会出来这个图 点击load ...
- 【学习笔记】【C语言】自增自减
1. 简单使用 ++ 自增运算符.如a++,++a,都等价于a = a+1 --自减运算符.如a--,--a,都等价于a = a-1 5++是错误的,因为5是常量 2. ++a和a++的区别 int ...
- 使用Eclipse maven构建springmvc项目
Eclipse maven构建springmvc项目 Listener 监听器 架构 使用Log4J监控系统日志邮件警报 2014-12-16 13:09:16 控制器在完成逻辑处理后,通常会产生一些 ...
- 利用二维矩阵求spanning tree
只做了9个节点的,无权值,使用了n-1个=8个循环,非常麻烦.一级一级判断是否连接,连接及记录所在节点,以后不再使用,确保无回路. 验证后无回路,但只试过几种情况. 代码如下: #include< ...
- Google面试题:计算从1到n的正数中1出现的次数
题目: 输入一个整数n,求从1到n这n个整数的十进制表示中1出现的次数.例如输入12,从1到12这些整数中包含1 的数字有1,10,11和12,1一共出现了5次. 找工作,准备看写题目,题目说是Goo ...
- 判断不在Update Task中
CALL FUNCTION 'TH_IN_UPDATE_TASK' IMPORTING IN_UPDATE_TASK = IN_UPDATE_TASK. "0 then not ...
- 预处理C#
1.什么是预处理 源代码指定了程序的定义.预处理(preprocessior directive)指令是指示编译器如何处理源代码.这里的预处理和C,C++里面的预处理是不一样的,在C,C++中有实际的 ...
- Unity3d 动态批处理的问题
这段时间做unity3d的优化,主要的入手是减少draw call. 1.代码上主要是把一些零碎的同材质的合并成一个大的mesh. 2.减少不必要的全屏后期处理.把摄像机的renderin ...