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
Post a Comment