|
|
On Wed, 23 Jan 2002 17:54:07 -0500, Christopher James Huff wrote:
> In C++, if you have a derived object that implements a certain method
> not in its base class, but only have a base-class pointer to it, you
> can't call that method unless you cast to that type. It's a pain that
> produces ugly code, that's all. In Objective C, the methods you can call
Only if you let it.
Clearly Warp hasn't asked the right question. The right question is, why
do you have a base-class pointer if you want a derived-class pointer?
The reason for all this is pretty simple. If all you have is a base-class
pointer, how do you know that it's a pointer to an instance of the right
derived class? Without more information, you don't. The cast is how you
tell the compiler that it's all right, you've thought of that, and you
really do want to do what you're doing.
--
#macro R(L P)sphere{L __}cylinder{L P __}#end#macro P(_1)union{R(z+_ z)R(-z _-z)
R(_-z*3_+z)torus{1__ clipped_by{plane{_ 0}}}translate z+_1}#end#macro S(_)9-(_1-
_)*(_1-_)#end#macro Z(_1 _ __)union{P(_)P(-_)R(y-z-1_)translate.1*_1-y*8pigment{
rgb<S(7)S(5)S(3)>}}#if(_1)Z(_1-__,_,__)#end#end Z(10x*-2,.2)camera{rotate x*90}
Post a reply to this message
|
|