Boost logo

Boost Users :

From: Lang Stefan (SLang_at_[hidden])
Date: 2008-03-05 07:35:15


Sorry folks for resending, but I forgot to change the subject line as
appropriate when I first replied to the digest. My bad...

For the sake of the initial poster (and anyone else interested in this
issue) to help him spot my response, below is a copy of that initial
reply. I cut away the rest of the digest as well as the original request
that I did quote originally, to keep redundancy to a minimum.

> Hi Stefan,
>
> My first guess would be to use initializers, as in
>
> NetworkMultiArray::NetworkMultiArray(int length)
> : boost::multi_array<double,3>( ... )
> {
> ...
> }
>
> You shouldn't need to explicitly use the this keyword unless you are
> using an obscure compiler and certain syntactically obscure
> constructs.
> However, if you want to refer to the methods of a superclass that you
> have overridden in your own class, use this class's name as a
> qualifier,
> e. g. if you have a method 'begin()' for your own class that overrides
> the 'multi_array::begin()' method, you will need to write
>
> boost::multi_array<double, 3>::begin();
>
> Usually, when you try to extend an existing class it is a good idea to
> create a typedef for your superclass, so it's easier to refer to it's
> methods. In your case define a typdef like this:
>
> typedef boost::multi_array<double, 3> super;
>
> If you do that, you can forward calls to method overrides of your own
> class to the baseclass by simply calling super::{_methodname_(...)}.
E.
> g. the above call would be reduced to
>
> super::begin();
>
> Note that some methods cannot be overriden, such as the copy
> constructors or assignment operators, so you will need to provide
those
> for your own class and explicitely call the base class methods inside:
>
> NetworkMultiArray& NetworkMultiArray::operator=(const
NetworkMultiArray& other)
> {
> super::operator=(other); // explicit use of operator= neccessary
here!
> // copy extended stuff here
> // ...
> return *this;
> }
>
>
> Hope this helps!
>
> Regards,
> Stefan (another one)


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net