auto和decltype
来源:互联网 发布:淘宝宝贝截图 编辑:程序博客网 时间:2024/05/26 02:54
//c++将常量存储在符号表中,不为const分配存储空间#include <iostream>using namespace std;struct{ char* name;}anon_u;struct{ int d; decltype(anon_u) id;}anon_s[100];int main(){ decltype(anon_s) as; int m = 1; cout << &m << endl; int& a = m; cout << &a << endl; auto c = a; //c为一个整数(忽略引用) int i = 0; const int j = i, &j1 = j; cout << &j << endl; auto p = j; //int auto q = j; //int auto r = &i; //r为一般指针 r = &m; *r =1; cout << r << endl; auto s = &j1; //s为常量指针 s = &m; //*s = 3; 编译不通过 const int d = 0; decltype(d) e = 0; //const int decltype(d + 2) f = 0; //返回表达式结果的类型 //如果decltype使用表达式的结果类型可以作为一条赋值语句的左值,那么decltype返回一个引用类型,例如解引用操作和变量加括号的类型 decltype(*s) g = 3; //返回int& decltype((d)) h = 1;//返回int& (d)为一个表达式 //如果表达式类型本身就是一个引用类型,那么decltype返回对应类型的引用类型 return 0;}
阅读全文
1 0
- auto和decltype
- 关于auto和decltype
- auto和decltype
- auto和decltype
- C++ auto和decltype
- auto和decltype
- C++14尝鲜:decltype 和 decltype(auto)
- C++11 auto 和decltype
- C++11 auto 和 decltype
- auto 和 decltype的区别
- C++11 decltype 和auto
- C++ auto和decltype浅析
- C++ 0x 之 decltype 和 auto
- C++11学习:auto和decltype
- C语言11中的auto和decltype
- C++11的auto和decltype关键字
- C++11 auto和decltype推导规则
- C++之decltype和auto的用法
- Java学习笔记---泛型
- PAT--1035. Password
- NYOJ 5 Binary String Mathing (substr函数)
- poj 2586
- 5_android的界面编程(UI)
- auto和decltype
- C++迭代器iterator段错误segmentation fault (core dumped)
- D.Innokenty and a football league
- 07-python学习笔记-列表生成式
- java多线程
- 程序员面试金典——n皇后问题_____(S)
- UDA1341(asoc)分析
- 【IO流】FileReader,FileWriter完成文件的copy
- Python入门学习(3)