By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,389 Members | 1,881 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,389 IT Pros & Developers. It's quick & easy.

dynamic types,

P: n/a
Does it make sense to talk about dynamic/static types with pointers in an
inheritance chain without virtual functions. You can still upcast/downcast.
Also, is it safe to say the static type is the pointer type you specify at
compile time, and the dynamic type is the type actualy pointed to---they may
be the same in the case A* a = new A();
Oct 4 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
* vsgdp:
Does it make sense to talk about dynamic/static types with pointers in an
inheritance chain without virtual functions.
Yes.

Also, is it safe to say the static type is the pointer type you specify at
compile time, and the dynamic type is the type actualy pointed to---they may
be the same in the case A* a = new A();
In general it's not safe to discuss terminology.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Oct 4 '06 #2

P: n/a

"Alf P. Steinbach" <al***@start.nowrote in message
news:4o************@individual.net...
>* vsgdp:
>Does it make sense to talk about dynamic/static types with pointers in an
inheritance chain without virtual functions.

Yes.

>Also, is it safe to say the static type is the pointer type you specify
at compile time, and the dynamic type is the type actualy pointed
to---they may be the same in the case A* a = new A();

In general it's not safe to discuss terminology.
What do you mean? Static and dynamic type are not well defined terms?

A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?

Oct 5 '06 #3

P: n/a
"vsgdp" <he***@null.comwrote in message
news:eYXUg.505$zf3.296@fed1read03...
Does it make sense to talk about dynamic/static types with pointers in an
inheritance chain without virtual functions. You can still
upcast/downcast.
Yes it does. Consider:

struct A { };
struct B : A { };

A* p = new B;
delete p; // undefined behavior

The statement "delete p;" has undefined behavior because the static type of
*p differs from its dynamic type and struct A doesn't have a virtual
destructor. If it didn't make sense for me to talk about static and dynamic
types in this context, how would I explain why "delete p;" has undefined
behavior?
Oct 6 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.