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

11 Years
Discussion Span
Last Post by Stoned_coder
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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.