GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 06-Dec-2005, 05:17
alcoholic's Avatar
alcoholic alcoholic is offline
Member
 
Join Date: Nov 2005
Posts: 170
alcoholic is on a distinguished road

calling static member function through object


Is there anything in the standards that we can't call static member function through objects...because everywhere i read it says that we call static member function by class name instead of object...but calling static member functions through object does works in all compilers....
I know that no implicit this pointer is passed in the static member functions...but is there any performance benefit by calling it though class name instead of objects.
  #2  
Old 06-Dec-2005, 05:33
Paramesh's Avatar
Paramesh Paramesh is offline
Regular Member
 
Join Date: Sep 2005
Location: The Milky Way
Posts: 927
Paramesh is a jewel in the roughParamesh is a jewel in the roughParamesh is a jewel in the rough
Thumbs up

Re: calling static member function through object


Quote:
Originally Posted by alcoholic
Is there anything in the standards that we can't call static member function through objects...
No.
Quote:
Originally Posted by alcoholic
because everywhere i read it says that we call static member function by class name instead of object...
Yes. We can call it. But there is one restriction, which you would already know.
Quote:
Originally Posted by alcoholic
but calling static member functions through object does works in all compilers....
Yes. It will work.
Quote:
Originally Posted by alcoholic
I know that no implicit this pointer is passed in the static member functions...but is there any performance benefit by calling it though class name instead of objects.
There is one benefit: Why confuse the program with calling it with an object?

Regards,
Paramesh.
__________________

Don't walk in front of me, I may not follow.
Don't walk behind me, I may not lead.
Just walk beside me and be my friend.
  #3  
Old 06-Dec-2005, 06:01
alcoholic's Avatar
alcoholic alcoholic is offline
Member
 
Join Date: Nov 2005
Posts: 170
alcoholic is on a distinguished road

Re: calling static member function through object


Quote:
Originally Posted by Paramesh
There is one benefit: Why confuse the program with calling it with an object?
So you mean..no performance benefit?
  #4  
Old 06-Dec-2005, 06:10
Paramesh's Avatar
Paramesh Paramesh is offline
Regular Member
 
Join Date: Sep 2005
Location: The Milky Way
Posts: 927
Paramesh is a jewel in the roughParamesh is a jewel in the roughParamesh is a jewel in the rough

Re: calling static member function through object


Quote:
Originally Posted by alcoholic
So you mean..no performance benefit?
Yes. There is no difference..


Paramesh.
__________________

Don't walk in front of me, I may not follow.
Don't walk behind me, I may not lead.
Just walk beside me and be my friend.
 
 

Recent GIDBlogMeeting the local Iraqis by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Tutorial] Function Pointers aaroncohn C++ Forum 4 17-Feb-2006 11:33
[Tutorial] GUI programming with FLTK dsmith FLTK Forum 10 03-Oct-2005 15:41
Why static member function cannot be virtual in C++ Poolan C++ Forum 1 20-Nov-2004 09:51
Revising Script style ?????? pepee MySQL / PHP Forum 4 14-Apr-2004 04:59

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 11:28.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.