c++ - how to assign an array from an initializer list -


i have limited knowledge c++. tried compile c++ library , when run make file following header file

mcmc_dhs.h

#include <algorithm> #include <map>  // intrinsic shape , (reduced) shear add? //#define wlnoise  // use shear instead of reduced shear model //#define noredshear  /// parameters m200-concentration relation const number mcreal[2] = {9.59,-0.102}; // dolag et al. (2004) //const number mcreal[2] = {5.26,-0.100}; // neto et al. (2007) [millenium run]  /// critical density @ z=0 (h100=1) in [msun/mpc^3] const number rhocrit = exp(log(rhocrit)+3.*log(mpc)-log(msun));   /// 2 halo parameters: r200 (and concentration: 2) #define params 1  /// define region (square; twice value here) halo considers sources model #define region 10.0*arcmin  class mcmc_dhs : public mcmc {  public:    mcmc_dhs() :    data(), cosmohandler(0.3,0.7,0.21,0.8,0.04),     lenseff(), intrvar()     {       boundaries =      {{0,512},{0,512},{0.01,5.},{100.,3000.},{0.1,50}};     }   ~mcmc_dhs() {}    /// size of grid looking sources   static const int ngrid = 200; 

it returns following error message:

mcmc_dhs.h:55:67: warning: extended initializer lists available -std=c++11 or -std=gnu++11 [enabled default]       boundaries = {{0,512},{0,512},{0.01,5.},{100.,3000.},{0.1,50}};                                                                    ^ mcmc_dhs.h:55:17: error: assigning array initializer list       boundaries = {{0,512},{0,512},{0.01,5.},{100.,3000.},{0.1,50}};                  ^ in file included ../modules/matrix.h:15:0,                  ../modules/probdensity.h:4,                  ../modules/mcmc.h:4,                  mcmc_dhs.h:4, 

i appreciate if can help.

you cannot assign directly array after declaration. code same as

int main() {     double arr[2][2];     arr = { {1, 2}, {3, 4.5} }; // error } 

you have either assign value @ declaration

double arr[2][2] = { {1, 2}, {3, 4.5} }; 

or use loop (or std::copy) assign elements. since array seems member variable, can initialize in constructor initialization list:

 mcmc_dhs() : data(), cosmohandler(0.3,0.7,0.21,0.8,0.04),                lenseff(), intrvar(),                boundaries{{0,512},{0,512},{0.01,5.},{100.,3000.},{0.1,50}}  {      // rest of ctor implementation  } 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -