Skip to main content
The 2024 Developer Survey results are live! See the results

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

10
  • Your posted code does not use static anywhere, please show us the code that actually generates that error.
    – user4442671
    Commented Apr 30, 2020 at 7:45
  • Why don't you just use a global variable? (And why is this a class?)
    – molbdnilo
    Commented Apr 30, 2020 at 7:46
  • 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. Commented Apr 30, 2020 at 7:46
  • "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?
    – theWiseBro
    Commented Apr 30, 2020 at 7:46
  • 1
    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? Commented Apr 30, 2020 at 7:48