Skip to main content
The 2024 Developer Survey results are live! See the results
24 events
when toggle format what by license comment
May 19, 2023 at 19:06 answer added omkar sawant timeline score: 0
Apr 30, 2020 at 10:31 vote accept Jaswant Arya
Apr 30, 2020 at 10:31 vote accept Jaswant Arya
Apr 30, 2020 at 10:31
Apr 30, 2020 at 10:31 vote accept Jaswant Arya
Apr 30, 2020 at 10:31
Apr 30, 2020 at 10:04 vote accept Jaswant Arya
Apr 30, 2020 at 10:31
Apr 30, 2020 at 10:04 vote accept Jaswant Arya
Apr 30, 2020 at 10:04
Apr 30, 2020 at 8:47 answer added Scheff's Cat timeline score: 25
Apr 30, 2020 at 8:35 answer added Devansh Maurya timeline score: 16
Apr 30, 2020 at 8:16 history edited Scheff's Cat CC BY-SA 4.0
formatting improved, image embedded
Apr 30, 2020 at 8:09 comment added Scheff's Cat Btw. are you aware that a static member variable is very different from a non-static? A static member variable only has the scope of the class but there is only one global storage. I.e. if one instance changes the value it will be changed for all other instances as well (as static member variables actually doesn't belong to any instance).
Apr 30, 2020 at 8:02 comment added Scheff's Cat Definition of static variables in header files isn't a good thing in general. The header might be included more than once and so you get an ODR violation. (ODR - One Definition Rule). Qualifying this inline tells the compiler explicitly to sort it out by itself. FYI: Static data members.
Apr 30, 2020 at 8:00 comment added Scheff's Cat What about static inline int m=INT_MIN;?
Apr 30, 2020 at 7:57 comment added Jaswant Arya I have commented the line which shows the error. I know that I should not use static as it will be static for all the instances but what is the meaning of this error- "non-const static data member must be initialized out of line"
Apr 30, 2020 at 7:55 comment added Jaswant Arya I have commented to the line which shows the error.
S Apr 30, 2020 at 7:48 history edited Jaswant Arya CC BY-SA 4.0
some code was not covered
Apr 30, 2020 at 7:48 comment added Yksisarvinen I don't think I understand your reasoning for using static data member. static data members are shared between all instances of the class, do you really want every single object of your class to change value of m?
Apr 30, 2020 at 7:46 comment added theWiseBro "I need to update the value of variable m. Therefore I am using "static int" data type." - What does this even mean? Do you mean keeping it shared across all instances?
Apr 30, 2020 at 7:46 comment added Some programmer dude Please copy-paste the errors as text into the question. Then make sure that the minimal reproducible example you show actually causes the error. And please add a comment on the line where you get the error.
Apr 30, 2020 at 7:46 comment added molbdnilo Why don't you just use a global variable? (And why is this a class?)
Apr 30, 2020 at 7:45 review Suggested edits
S Apr 30, 2020 at 7:48
Apr 30, 2020 at 7:45 comment added user4442671 Your posted code does not use static anywhere, please show us the code that actually generates that error.
Apr 30, 2020 at 7:45 history edited user4442671 CC BY-SA 4.0
added 8 characters in body
Apr 30, 2020 at 7:43 review First posts
Apr 30, 2020 at 12:02
Apr 30, 2020 at 7:42 history asked Jaswant Arya CC BY-SA 4.0