文章分类 - 【4】C++11新特性
摘要:lambda 匿名函数 #include <iostream> #include <stdio.h> using namespace std; int main() { // []{} auto foo1 = [] {return 1 + 2; }; cout << foo1() << endl;
阅读全文
摘要:从此文章http://c.biancheng.net/view/6984.html参考! auto auto varname = value; 注意: auto 不能作为函数参数; auto 不能作为类的非静态成员变量(static); auto 不能定义数组 auto 仅是一个占位符不是类型声明;
阅读全文
摘要:话不多说,先上代码 class Apple { public: Apple(){ str = nullptr; } Apple(const char *another){ if (another==nullptr){ str = new char[1]; *str ='\0'; }else{ str
阅读全文
摘要:智能指针包含在头文件<memory>中总共四种: auto_ptr unique_ptr share_ptr weak_ptr 其中auto_ptr已经被弃用 智能指针的作用 方便管理堆内存,谨防堆内存二次泄露;普通的指针容易造成内存泄露,由于大量的堆内存数据都是由程序员手动申请和释放的,因此非常麻
阅读全文

浙公网安备 33010602011771号