POV-Ray : Newsgroups : povray.off-topic : Quick C++ question... Server Time
5 Sep 2024 03:19:57 EDT (-0400)
  Quick C++ question... (Message 21 to 25 of 25)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Darren New
Subject: Re: Quick C++ question...
Date: 12 Nov 2009 14:16:15
Message: <4afc5eff$1@news.povray.org>
Warp wrote:
> The inherited class using things like virtual functions and multiple
> inheritance does not affect the base struct part.

Cool. Not even C# manages that. (You can't put virtual methods on a value 
class.) Another win for C++ MI.

-- 
   Darren New, San Diego CA, USA (PST)
   I ordered stamps from Zazzle that read "Place Stamp Here".


Post a reply to this message

From: Warp
Subject: Re: Quick C++ question...
Date: 12 Nov 2009 14:56:51
Message: <4afc6882@news.povray.org>
Darren New <dne### [at] sanrrcom> wrote:
> Oh! OK. Heh. I don't think I've ever had the pleasure of needing or using 
> inner classes before, in any language, so it didn't leap out at me.

  Why not? It aids in limiting the visibility of types, and thus increases
modularity. If a class uses a helper class which is completely exclusive
to that class (and might even be a friend), then it makes sense that the
helper class is defined as a private inner class.

-- 
                                                          - Warp


Post a reply to this message

From: Warp
Subject: Re: Quick C++ question...
Date: 12 Nov 2009 14:58:57
Message: <4afc6901@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
> Darren New <dne### [at] sanrrcom> wrote:
> > Oh! OK. Heh. I don't think I've ever had the pleasure of needing or using 
> > inner classes before, in any language, so it didn't leap out at me.

>   Why not? It aids in limiting the visibility of types, and thus increases
> modularity. If a class uses a helper class which is completely exclusive
> to that class (and might even be a friend), then it makes sense that the
> helper class is defined as a private inner class.

  Forgot to mention practical examples.

  Ever wondered what, for example, std::list<int>::iterator is? Well,
surprisise surprise, it's an inner class inside std::list<int>. It's so
related to std::list that it makes a lot of sense to make it an inner class.

-- 
                                                          - Warp


Post a reply to this message

From: Darren New
Subject: Re: Quick C++ question...
Date: 12 Nov 2009 16:53:39
Message: <4afc83e3$1@news.povray.org>
Warp wrote:
> Darren New <dne### [at] sanrrcom> wrote:
>> Oh! OK. Heh. I don't think I've ever had the pleasure of needing or using 
>> inner classes before, in any language, so it didn't leap out at me.
> 
>   Why not? 

I just haven't needed it. In languages where there's specific header files 
(i.e., C and C++), I don't include the header file for the child class. In 
languages where there's specific support for the concept (C#) I use the 
internal visibility. I haven't done much in Java since they invented inner 
classes, but those aren't really "invisible" so much as obsfucated anyway, 
so there didn't seem to be a benefit there either.

I.e., everyone already has modular visibility controls, so putting it inside 
a class rather than a namespace didn't seem worthwhile.

> It aids in limiting the visibility of types, and thus increases
> modularity. If a class uses a helper class which is completely exclusive
> to that class (and might even be a friend), then it makes sense that the
> helper class is defined as a private inner class.


Yes it does. I didn't say it was bad. I just said I never found the need to 
use one. The existent mechanisms were already sufficient.


-- 
   Darren New, San Diego CA, USA (PST)
   I ordered stamps from Zazzle that read "Place Stamp Here".


Post a reply to this message

From: Darren New
Subject: Re: Quick C++ question...
Date: 12 Nov 2009 17:55:13
Message: <4afc9251$1@news.povray.org>
Darren New wrote:
> Yes it does. I didn't say it was bad. I just said I never found the need 
> to use one. The existent mechanisms were already sufficient.

Altho your point of a public class with an embedded iterator is a good one. 
I even expect C# uses embedded classes to implement that in the libraries, 
now that you mention it. Of course, the name isn't exposed outside the class 
in any way, so it's hard to tell without reading actual source code. 
Instead, there's a call called "getEnumerator" or something on the 
collection that returns something that inherits the Enumerator interface or 
some such. You don't directly instantiate an iterator, but rather ask the 
class for one.

-- 
   Darren New, San Diego CA, USA (PST)
   I ordered stamps from Zazzle that read "Place Stamp Here".


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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