Interesting issue with regards to the way this site works. Anything more than four characters in the answer is just excessive verbiage. But the site won't let you post an answer with just four characters.
–
James KanzeFeb 13 '13 at 9:37

But it our lectures it says: Static member functions may access only static data members. I tried and it works. So how can it work? If the function is static who's field is it accessing? If the field is not static then it belongs to a specific object..
–
dlvFeb 13 '13 at 9:57

Here you access a member of an argument. Static functions can do whatever they want with their arguments. Problem is they have no access with instance members because there is no instance associated with them.
–
Ivaylo StrandjevFeb 13 '13 at 9:58

I did not try to access a member of an arguement. I accessed an actual field of the class..
–
dlvFeb 13 '13 at 10:08

1

@div show us an example of what you did. What you say can not work.
–
Ivaylo StrandjevFeb 13 '13 at 10:09

1

@dlv Put it in your original question, properly formatted, also with an example on ideone.com.
–
Peter WoodFeb 13 '13 at 12:28

Access rights and whether a function is static or not are
orthogonal concepts. A member function can access all members,
private, protected or public. Regardless of whether it is
static or not. A static member function has no this pointer,
however, and non-static members require an object in order to be
accessed (or even to exist). So if the static function is to
access non-static members, it must obtain a pointer or
a reference to another object (or create one as a local
variable, but this is really rare). So: