We cannot have static friend function...is it because

1.since static member functions can access only static data members...whereas friend function can access all the members.

2.friend function also require an object to access the members...wheeras static member functions can not.

3.One more thing....since friend functions are non-member functions....and static functions are member functions

Am i right.....if there is an error..plz correct....or a better or different reason ...the plz add

static int func(); // proto for a static func

class AClass
   friend int func(); // can be a friend and retains its static linkage
   friend int anotherfunc(); // assumed to have external linkage

Static funcs can be friends. A static member can also be used to access an objects internals as long as it recieves a this pointer explicitly when its called. This trick is often used when wrapping the win32 api up to have a static wndproc pass down the messages to a virtual wndproc. This is done usually by storing the this pointer as a windowlong and retrieving it in the static func so that the virtual wndproc can be called.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.