POV-Ray : Newsgroups : povray.unofficial.patches : pvmpovray35 release : Re: pvmpovray35 release Server Time
8 Jul 2024 18:13:19 EDT (-0400)
  Re: pvmpovray35 release  
From: Warp
Date: 13 Dec 2002 03:52:54
Message: <3df99fe6@news.povray.org>
Michael Goldshteyn <mgo### [at] n-o-s-p-a-m-earthlinknet> wrote:
> Maybe in C, in C++ your types and constants should have the scope of the
> class or namespace they are defined in, thus only cluttering that namespace,
> if you can even consider that clutter.

  Naturally, but even in C++ the same principle holds: Types and constants
used only inside the module should be defined in the .cpp file, not the
header file.

  Of course the exception to this in C++ are the definitions in the private
part of the (public) class, which must be declared in the same place as the
class itself (ie. in the header). Even though this is cumbersome, the reason
for this is purely technical: The compiler must know the size of the class
everywhere it's used, and member variables inside the class need to be known
in order to know this size (regardless of where they are inside the class).

  One thing which I don't like and don't agree is that in C++ you also must
declare all private methods and types in the same class definition as well.
There's no technical nor syntactical need for this. It would be perfectly
possible to declare private methods and types separately from the class
definition itself.
  For example, I don't see any problem in supporting something like this:

(In file.hh)

class Whatever
{
 public:
    void f();

 private:
    int a;
};

(In file.cc)

void Whatever::f() // Implementation of the public method f()
{
    ...
}

typedef double Whatever::D; // A private type declaration

void Whatever::g() // Declaration and implementation of a private method g()
{
    ...
}

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

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