c++ - why i can pre-compile c'tor of father but not his attribute? cpp -


good morning. when tring pre-compile (i dont know real name of this..) father c'tor this:

point_3d(int _x, int _y, int _z) :point_2d(_x, _y, _z), z(_z+100){}; 

its working. when trieng this:

point_3d(int _x, int _y, int _z) :point_2d(_x, _y, _z), _x(4), z(_z+100){}; 

it doesnt. (the '_x' parameter belongs father.) , little question: why cant pre-compile '=' , must use '()'? thanks!

assuming _x(4) refers member of point_2d class, can initialized owning class, not derived classes.

the initalizer list can contain base classes , members of current class, not members of base classes.

but wouldn't

point_3d(int _x, int _y, int _z) :point_2d(4, _y, _z), z(_z+100){}; ___________________________________________^ 

do want?


Comments

Popular posts from this blog

gridview - Yii2 DataPorivider $totalSum for a column -

java - Suppress Jboss version details from HTTP error response -

Sass watch command compiles .scss files before full sftp upload -