POV-Ray : Newsgroups : povray.off-topic : Binary trees, branches and leaves : Re: Binary trees, branches and leaves Server Time
4 Sep 2024 15:19:52 EDT (-0400)
  Re: Binary trees, branches and leaves  
From: Invisible
Date: 5 Mar 2010 08:11:18
Message: <4b9102f6$1@news.povray.org>
Warp wrote:

>   However, can this be called object-oriented? Having objects in an array
> excludes the possibility of using objects of a derived type (unless an
> object of the derived type has the exact same size as the base type object;
> even then it requires some low-levelish trickery to get it working, at
> least in C++, and probably other languages where objects can be handled
> by value and put into arrays). However, one of the basic ideas of OOP is
> that whenever an object of type A is expected, an object of type B can be
> given to it instead, if B has been derived from A (or from any of its
> subclasses). An array of objects wouldn't support this.

Wouldn't you just need to determine the storage requirements of THE 
LARGEST class of object? And allocate that amount for every object?

Granted, I don't actually know of a language or compiler which actually 
supports this...

(In particular, if you can add new subclasses dynamically at runtime, 
this approach obviously won't work at all. But if all classes are known 
at compile-time, it's feasible in principle.)


Post a reply to this message

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