Hello. The question is, there are 2 structures. How to correctly declare a default constructor in the One structure? Interests specifically in the case of an array of point structures from 50 elements? so that it is initialized by default with the Reach constructor values ​​for all 50 elements

#include ".\Point.h" struct Reach { unsigned short az; Point location; float block; Reach(unsigned short _az = 0, Point _point = Point(), float _block = 0.0f) : az(_az) , location(_location) , block(_block) {} }; struct One { unsigned short number; Reach point[50]; // Точки bool isMin; One(unsigned short _number = 0, bool _isMin = false) : number(_number) , point() , isMin(_isMin) {} }; 

1 answer 1

Instances of the Reach class in the array Reach point[50] will be initialized by the default constructor of the Reach class. Those. the constructor you wrote with the default parameters.

For this, it was possible not to mention the point at all in the initialization list of the One constructor. The language already guarantees calling the default constructors for the elements of your array. But the explicit mention in the form of point() , as you have now, will also give the same effect.

  • Thank. I was not completely sure that this was the right approach. - Disastricks