Is this warning alright - “#368-D: define

2019-09-12 08:30发布

问题:

In my C++ code, I have a const array of objects of a struct type. This structure has some const members.

My hardware compiler (GHS Multi2000) throw the warning:

warning#368-D: class defines no constructor to initialize the following:

Is this warning alright? I read online that this can be ignored. It is simply that the compiler expects const members to be initialized in the constructor initialization list. Can this warning be suppressed?

回答1:

The warning is all right, and meaningful. What value do you expect these const members to have, without an initializer? So why not remove them then?