Casting

Started by
12 comments, last by Landsknecht 21 years, 11 months ago
You know. AP always confuses me. I can understand why people use AP when they are flaming, but why when they are actually being remarkably informative?

The AP up there actually had my answer. It makes sense now. Still seems like to much extra typing, but at least I understand now.

Thanks AP,
Landsknecht
My sig used to be, "God was my co-pilot but we crashed in the mountains and I had to eat him..."
But folks whinned and I had to change it.
Advertisement
hes probably too lazy to log in. or perhapse doesnt trust the location he posts at (work,a net cafe, or something)

i dunno. maybe its just best to let him explain.

or maybe its a she.... and we would always comment on how a girl knows so much etc etc. maybe "she" has had enough of the sexism.

i also just noticed that it allows AP to get out of viewing profile and sending mail to regarding the post.

[edited by - noober on April 30, 2002 12:51:06 AM]
quote:Original post by Landsknecht
The AP up there actually had my answer. It makes sense now. Still seems like to much extra typing, but at least I understand now.

There''s even a reason for the extra typing. Casts have been proven over time to be a constant source of bugs. Therefore, it makes sense to make them easy to find in the source; the c-style casting syntax is far too subtle.

[C++ FAQ Lite | ACCU | Boost | Python]
quote:Dynamic casting is used when you are not sure what type a variable is. If that type is castable to the one you want it to then dynamic_cast<>() returns true. Otherwise it returns false. This allows you to do run-time type checking if that becomes necessary. It is relatively new so many compilers don''t implement it properly.

No it doesn''t.

dynamic_cast<>() on pointers returns NULL if the cast was bad, or a valid pointer if it was OK.

dynamic_cast<>() on references throws a bad_cast exception if the cast was bad, or a valid reference if it was OK.
char a[99999],*p=a;int main(int c,char**V){char*v=c>0?1[V]:(char*)V;if(c>=0)for(;*v&&93!=*v;){62==*v&&++p||60==*v&&--p||43==*v&&++*p||45==*v&&--*p||44==*v&&(*p=getchar())||46==*v&&putchar(*p)||91==*v&&(*p&&main(0,(char**)(--v+2))||(v=(char*)main(-1,(char**)++v)-1));++v;}else for(c=1;c;c+=(91==*v)-(93==*v),++v);return(int)v;}  /*** drpizza@battleaxe.net ***/

This topic is closed to new replies.

Advertisement