Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[C++]½Ð°Ý¦¹µ{¦¡¤¤typeidªº¨Ï¥Îªk­þùØ¿ù¤F¡H

0 views
Skip to first unread message

少年遊

unread,
Aug 30, 2001, 2:13:33 PM8/30/01
to
請問小弟在程式中typeid的使用法哪裏錯了?

#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

0 new messages