Hi Stefan,
My first guess would be to use initializers, as in
NetworkMultiArray::NetworkMultiArray(int length)
: boost::multi_array
-----Original Message-----
Message: 3 Date: Tue, 4 Mar 2008 16:21:12 +0100 From: "Klett, Stefan"
Subject: [Boost-users] Extending Multi Array To: Message-ID: <53834FBAA22A7F43B76C1BCD2D5A09D3026B16A0@FZKMSX6.ka.fzk.de> Content-Type: text/plain; charset="us-ascii" 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
{ 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