|
|
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
|
|