POV-Ray : Newsgroups : povray.programming : void pointer array problem : Re: void pointer array problem Server Time
28 Jul 2024 08:25:58 EDT (-0400)
  Re: void pointer array problem  
From: Warp
Date: 14 Jul 2002 11:46:58
Message: <3d319cf1@news.povray.org>
Thomas Willhalm <tho### [at] uni-konstanzde> wrote:
> In C++, you can use templates to design them generic in the sense that the
> coder of the container class does not have to know the type of objects
> that are inserted while still ensuring at compile time that the same kind
> of objects is inserted or returned. (In case you want to insert objects
> of different type the right way to do it is of course - as you wrote -
> to create a common base class.) 

  Yes, templates are really handy for things like this (and that's why AFAIK
they are planning to add templates to Java as well).
  Of course it has the limitation that you can only store one type of objects
inside a certain instance of the container. If you need to store different
type of objects, you need to store only base-class-type pointers (and the
objects themselves have to be created separaterly, usually dynamically).

> In Java however, I don't know any other way than inserting and returning
> objects of type "object". IMO this is as bad as inserting and returning
> "void*". So you can avoid "object" in Java and "void*" in C++ if you
> design the items that are inserted in your container, but you can't
> avoid "object" if you don't.

  Even though in most cases an Object reference is practically the same
thing as a void*, it still is better than void*. I think that Object has
some properties (ie. methods).

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

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