Boost logo

Boost Users :

From: frederic.bron_at_[hidden]
Date: 2008-03-04 11:12:37


It is a bad idea to derive from a class which destructor is not virtual like multi_array
You should better use composition (i.e. multi_array is a member of your matrix class).
Regards,

F. Bron

boost-users-bounces_at_[hidden] a écrit sur 04/03/2008 16:21:12 :

> Hi list members,
>
> This is a more or less a general kind of " how to extend container
> classes" question -
> I'm trying to write a class which inherits from boost::multi_array - the
> to get a kind of matrix class with some additional service routines.
> Maybe it is a lack of experience - but I for the time being I don't know
> how to solve the problem to access the constructor of multi_array in my
> own class to initialize my matrix class - my current guess was to use
> the "this" pointer but it had not worked out like I supposed it to do.
>
> class NetworkMultiArray: public boost::multi_array<double,3>
> {
> public:
> NetworkMultiArray(int);
> virtual ~NetworkMultiArray();
> };
>
> Here is the constructor code:
>
>
> NetworkMultiArray::NetworkMultiArray(int length)
> {
> this::iterator iter3;
> typedef this::template subarray<2>::type::iterator iter2;
> typedef this::template subarray<1>::type::iterator iter1;
>
> for( iter1 i = *this.begin(); iter1 != *this.end(); iter1++){
> for(iter2 ii = (*i).begin(); ii != (*i).end(); ii++){
> for(iter3 iii = (*ii).begin(); iii !=
> (*ii).end(); iii++){
> *iii = 0.0 ;
> }
> }
> }
> }
> sure this does not work - and is the result from trying to adapt the
> iterator example from the documentation.
>
> my aim is to handle the NetworkMultiArray like a boost::multi_array and
> initialize it to zero - further it would be nice if somebody could tell
> me how I could assign a length to the array and the subarrays.
> The key-point is that I want to use my class (NetworkMultiArray) like a
> multi_array by inheritance of the multi_array features of
> boost:multi_array.
>
> Thank you very much in advance.
> Best regards
> Stefan

Avis :
Ce message et toute pièce jointe sont la propriété d'Alcan et sont destinés seulement aux personnes ou à l'entité à qui le message est adressé. Si vous avez reçu ce message par erreur, veuillez le
détruire et en aviser l'expéditeur par courriel. Si vous n'êtes pas le destinataire du message, vous n'êtes pas autorisé à utiliser, à copier ou à divulguer le contenu du message ou ses pièces jointes
en tout ou en partie.

Notice:
This message and any attachments are the property of Alcan and are intended solely for the named recipients or entity to whom this message is addressed. If you have received this message in error
please inform the sender via e-mail and destroy the message. If you are not the intended recipient you are not allowed to use, copy or disclose the contents or attachments in whole or in part.


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