POV-Ray : Newsgroups : povray.off-topic : C++ question for the experts : Re: C++ question for the experts Server Time
29 Jul 2024 20:27:55 EDT (-0400)
  Re: C++ question for the experts  
From: Darren New
Date: 15 May 2011 12:38:07
Message: <4dd0016f$1@news.povray.org>
On 5/15/2011 1:22, Warp wrote:
> Darren New<dne### [at] sanrrcom>  wrote:
>> Is it possible to put a class into a variable in C++?
>
>    C++ isn't dynamic like that, so the short answer is "no".
>
>    There are techniques to somewhat simulate that, although it's probably a
> bit limited. Googling for "factory pattern c++" might give some ideas.
>
>    As a side note, Objective C *does* support this out-of-the-box (which
> shouldn't be surprising to you at this point, I suppose).

Yeah. Objective-C seems almost exactly like "let's put smalltalk in C", even 
down to the syntax.

The reason I asked is I was having a conversation with someone, and I said 
Smalltalk and Python and Ruby have classes as first-class objects, Java and 
C# have them as "sort of" first class objects, and many others like C++ 
don't.  I had to explain the "sort of" of course, and I wanted to make sure 
there wasn't anything in C++ that would fill the "sort of" roll that the 
"Type" data type does in C# or whatever the equivalent in Java is that I 
don't remember right now.

-- 
Darren New, San Diego CA, USA (PST)
   "Coding without comments is like
    driving without turn signals."


Post a reply to this message

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