943,810 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 3820
  • C RSS
Oct 4th, 2005
0

static friend function

Expand Post »
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
Similar Threads
SpS
Reputation Points: 70
Solved Threads: 32
Posting Pro
SpS is offline Offline
598 posts
since Aug 2005
Oct 4th, 2005
0

Re: static friend function

  1. static int func(); // proto for a static func
  2.  
  3. class AClass
  4. {
  5. friend int func(); // can be a friend and retains its static linkage
  6. friend int anotherfunc(); // assumed to have external linkage
  7. };
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.
Reputation Points: 19
Solved Threads: 5
Junior Poster
Stoned_coder is offline Offline
164 posts
since Jul 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: print out problem
Next Thread in C Forum Timeline: RC4 project





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC