Timeline for Static const member initialization outside class
Current License: CC BY-SA 4.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 25, 2020 at 19:46 | comment | added | Quarra | If it needs to be initialized from main, then most probably it doesn't belong to the class in the first place, hence XY problem. Entities shall be defined as close as possible to where they are declared. | |
Nov 25, 2020 at 17:42 | comment | added | user12918858 | @Quarra and how to initialize from main? | |
Nov 25, 2020 at 17:39 | comment | added | Quarra |
@user12918858 to me it is a xyproblem.info: you're asking about how to handle a case that is already solved in modern C++: no need to discuss initialization outside the class if it can (and should) be done where it's declared (so inside, with inline ).
|
|
Nov 25, 2020 at 14:57 | comment | added | t.niese | @user12918858 I didn't say anything else in my comment? | |
Nov 25, 2020 at 14:51 | comment | added | user12918858 | @t.niese please read carefully. I want to initialaize members out of class. Can i do it?? | |
Nov 25, 2020 at 14:12 | comment | added | t.niese |
While I personally agree that this is probably the cleanest way to do it, the question is how can i initialize static const int member outside class ? and that one is not outside of the class. Maybe it is what the OP is looking for, but then the question is asked incorrectly by the OP.
|
|
Nov 25, 2020 at 14:02 | history | answered | Quarra | CC BY-SA 4.0 |