c++/oop---c++11 特性/类型

c++11

 

auto 关键字

自动判断变量的类型

查看代码
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
using namespace std;
set<int>s;
int main(){
	for(int i=1;i<=10;i++)s.insert(rand());
	for(auto i=s.begin();i!=s.end();i++){
		printf("%d \n",*i);
	}
	return 0;
}

 

decltype

 

int i;
double t;
struct A { double x; };
const A* a = new A();
decltype(a) x1; // x1 is A *
decltype(i) x2; // x2 is int
decltype(a->x) x3; // x3 is double
decltype((a->x)) x4 = t; // x4 is double&
decltype (f()) x5 ;// x5 is the type of f 

 

posted @   liankewei123456  阅读(23)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示