c++ - initialize boost::multi_array in a class -


for start newbie.

i trying initialized boost:multi_array inside class. know how create boost:multi_array:

boost::multi_array<int,1> foo ( boost::extents[1000] ); 

but part of class have problems:

class influx {     public:     influx ( uint32_t num_elements );     boost::multi_array<int,1> foo;  private:  };  influx::influx ( uint32_t num_elements ) {     foo = boost::multi_array<int,1> ( boost::extents[ num_elements ] ); } 

my program passes through compilation during run-time error when try accuse element foo (e.g. foo[0]).

how solve problem?

use initialisation list (btw, know zip bit of boost, i'm going code):

influx::influx ( uint32_t num_elements )     : foo( boost::extents[ num_elements ] ) { } 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -