[問題] typeinfo about const
我玩了一下 typeinfo 的功能,
想比較一下 int 型別 與 const int 型別
結果出乎我意料的 typeid(int) == type(const int)
回傳的結果是 true @@"
我稍微 google 了一下,找不到關於 typeinfo 與 const 的關西
讓我陷入了苦惱 #(┬_┬)#
請教各位高手有什麼看法呢?
謝謝
我目前用的是 Visual Studio 2005
以下是我的 test code
#include <iostream>
#include <typeinfo>
using namespace std;
int main()
{
int ia;
cout << "ia is: " << typeid(ia).name() << endl;
const int cia = 0;
cout << "cia is: " << typeid(cia).name() << endl;
if(typeid(ia) == typeid(cia))
cout << " ia == cia";
else
cout << " ia != cia";
cout << endl;
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.43.16.28
→
12/19 19:11, , 1F
12/19 19:11, 1F
→
12/19 19:45, , 2F
12/19 19:45, 2F
推
12/19 19:46, , 3F
12/19 19:46, 3F
→
12/19 21:25, , 4F
12/19 21:25, 4F
→
12/19 21:26, , 5F
12/19 21:26, 5F
→
12/19 21:27, , 6F
12/19 21:27, 6F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章