POV-Ray : Newsgroups : povray.off-topic : Binary trees, branches and leaves : Re: Binary trees, branches and leaves Server Time
8 Oct 2024 10:04:01 EDT (-0400)
  Re: Binary trees, branches and leaves  
From: Darren New
Date: 5 Mar 2010 14:07:43
Message: <4b91567f$1@news.povray.org>
Warp wrote:
>   One interesting question: If objects are in an array rather than being
> individually allocated (and handled through references/pointers), can it
> still be called object-oriented?

I would think so. Inheritance is just one part of the OO thing.

 > An array of objects wouldn't support this.

It could, if you allocate enough space in the array for child types. Of 
course this breaks if you start loading new child classes at runtime. You 
just artificially inflate the size you allocate to be large enough.

You're also running into the covariance problem. If you have

virtual A* x(B*) { ... }

(i.e., a function x that take an instance of B or one of B's subclases as an 
argument, and returns an instance of class A or one of A's children...)

what is a subclass that overrides that x allowed to declare as a return type 
and an argument type?  Is it allowed to accept only C*, where C is a child 
of B?  Is it allowed to accept D*, where D is a parent of B?  Now ask the 
same about A, and you get a completely different answer.

-- 
Darren New, San Diego CA, USA (PST)
   The question in today's corporate environment is not
   so much "what color is your parachute?" as it is
   "what color is your nose?"


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.