Redian新闻
>
Does VC++ 6.0 not support dynamic cast?
avatar
Does VC++ 6.0 not support dynamic cast?# Programming - 葵花宝典
n*d
1
How come this code crash in runtime by VC++ 6.0?
#include
using namespace std;
class Pet { public: virtual ~Pet(){}};
class Cat : public Pet {};
int main() {
Pet* b = new Cat; // Upcast
Cat* d = dynamic_cast(b);
}
avatar
h*e
2
VC6 is buggy. Use something else.

【在 n**d 的大作中提到】
: How come this code crash in runtime by VC++ 6.0?
: #include
: using namespace std;
: class Pet { public: virtual ~Pet(){}};
: class Cat : public Pet {};
: int main() {
: Pet* b = new Cat; // Upcast
: Cat* d = dynamic_cast(b);
: }

avatar
n*d
3
How could it be in the market if it has so obvious bug?!

【在 h*******e 的大作中提到】
: VC6 is buggy. Use something else.
avatar
s*e
4
You could turn on the RTTI (in Project->Setting->C/C++->C/C++ Language) to
avoid this. You should have noticed the warning C4541: 'dynamic_cast' used
on polymorphic type ...
Anyway, this should be part of the C++ language, not an option.

【在 n**d 的大作中提到】
: How could it be in the market if it has so obvious bug?!
avatar
d*q
5
vc 6.0 only covers 80% std c++,don't expect you can use tricks with this
compiler
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。