c++11 - const * const * member variable initialization c++ -


i having trouble initialization of struct (simplified example)

struct s{ const float * const * const data;}; 

basically have buffer of buffers of floats, , use const ensure using s cannot change member (read only).

my problem complicated , hard read initialize, use lambda return const s, , initialize members in lambda writing member name : s.data = ptr;

now code complex , wonder better solution.

afaik, having struct s{float ** data;} const s not protect efficiently content of member, not modify s::data, modify *s::data.

how should ?

thank

why not remove last const?

struct s{ const float * const * data;}; 

that way can initialize data like, , still can't used modify points to.

data can modified, should prevented, should private.


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -