Search code examples
c++functionstaticnon-static

Can a static variable be access by nonstatic functions?


My questions is: if a static variable (access level: private) is defined in a class and we want to access it by non static function of that class. . is it possible in c++?


Solution

  • The answer is yes.

    This question was already somewhat asked here: Can non-static methods modify static variables

    You are just asking if it can access it though - I am fairly certain if you can modify something, that means you can also access it.