+ 4
why static member function cannot access non static data?
3 ответов
+ 5
Static member function belongs to the program. Non static members belong to the object. So how is static member function supposed to know, which object's data it us supposed to use, if it doesn't have any notion about objects? If you have 2 objects of a class: A and B, when you call a static member function of that class, which object's data it is supposed to access, if there's by definition one and only one shared static implementation of that static member function?
0
And Do not forget static function can not acess not static directly but if you define an instance then you can use non static members