#include <iostream>
#include <typeinfo>
class Dummy {
};
int main() {
Dummy* a;
Dummy b;
std::type_info& fa = typeid(a);
std::type_info& fb = typeid(b);
if (fa != fb) {
std::cout << "a is: " << fa.name() << std::endl;
std::cout << "b is: " << fb.name();
}
return 0;
}
以下為編譯時產生的錯誤訊息
Warning W8028 D:\CPPDEMO\Test.cpp 10: Temporary used to initialize
'fa' in function main()
Error E2247 D:\CPPDEMO\Test.cpp 10:
'std::type_info::type_info(const std::type_info &)'
is not accessible in function main()
Warning W8028 D:\CPPDEMO\Test.cpp 11:
Temporary used to initialize 'fb' in function main()
Error E2247 D:\CPPDEMO\Test.cpp 11:
'std::type_info::type_info(const std::type_info &)'
is not accessible in function main()
*** 2 errors in Compile ***
--
[m○ Origin: 新竹師院 風之坊﹝bbs.NHCTC.edu.tw﹞From: tp222-72.dialup.seed.net.tw