#include <iostream>
#include<typeinfo>
using std::cin;
using std::cout;
using std::endl;
auto f(auto x)
{return x+1;}
auto f(auto x,auto y)->decltype(y){
return x-y;
}
double func()
{
cout<< "func executed." << endl;
return 2.5+3.6;
}
int main()
{
decltype(func()) sum;
cout<< typeid(sum).name() << endl;
const int ci = 0, &cj = ci;
decltype(ci) x= 0;
decltype(cj) y= x;
//decltype(cj) z;// compile error: ‘z’ declared as reference but not initialized cout << typeid(x).name() << endl;
cout<< typeid(y).name() << endl;
int i = 10, *p = &i, &r = i;
decltype(r+ 0) b;
//decltype(*p) c;// compile error: ‘c’ declared as reference but not initialized cout << typeid(b).name() << endl;
decltype(i) u;
//decltype((i)) v;// compile error: ‘v’ declared as reference but not initialized
return 0;
}
新聞名稱:decltypetypename-創(chuàng)新互聯(lián)
標(biāo)題鏈接:http://jinyejixie.com/article24/diesje.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站策劃、用戶體驗(yàn)、電子商務(wù)、動(dòng)態(tài)網(wǎng)站、App開發(fā)、網(wǎng)頁設(shè)計(jì)公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容