POV-Ray : Newsgroups : povray.off-topic : Visual C# .net (and XNA) first impressions : Re: Visual C# .net (and XNA) first impressions Server Time
5 Sep 2024 09:20:31 EDT (-0400)
  Re: Visual C# .net (and XNA) first impressions  
From: Warp
Date: 12 Oct 2009 19:03:00
Message: <4ad3b5a3@news.povray.org>
Darren New <dne### [at] sanrrcom> wrote:
> Where did I say everything is public?  I just said that the private methods 
> wind up being visible in the public "interface" file in C++.  Again, I was 
> just commenting in terms of people complaining there was too much "visible" 
> in the C# way of doing things.

  A header file is not really a "public interface". It's just a source code
file like any other. The "public interface" of a class is what you put
inside the "public" section of the class. Whatever there might be in the
"private" section is there purely for technical reasons, and you shouldn't
concern yourself about it and consider it effectively hidden (at least if
you want to maintain good OOD).

  Yes, a class declaration cannot be split into two or more parts in C++
(for technical reasons), but that doesn't make the private part any more
"public".

  There are other programming languages (such as Objective-C) where you
can split the class declaration into two, putting one part in a header
file and the other in the source file, but that's because the way objects
are implemented allows that (at the cost of speed and memory efficiency).

> > You can replace them with
> > local functions (ie. local to the compilation unit, ie. in a nameless
> > namespace).

> Hmm. But you don't get a "this" pointer, right? You need to start being 
> explicit about everything that OO is supposed to make implicit, like 
> accessing member variables from inside the function and all?

  The 'this' pointer is passed implicitly to member functions by the
compiler. If you decide to make it a local function instead, you'll have
to pass the object pointer explicitly as a function parameter. Otherwise
there isn't too much of a difference, just a small difference in syntax.

  (The real difference between private member functions and local
functions is access scope.)

-- 
                                                          - Warp


Post a reply to this message

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