What is the difference between static method and member function? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the difference between static method and member function?

All the class objects are going to use the member function only .Unlike Member variables , separate memory space for each member function are not allocated for each objects and all objects are going to share them.So apart from invoking (class.function and obj.function) what is the real difference between them and which one is best to use

28th Aug 2018, 3:09 AM
Prakash
Prakash - avatar
9 Answers
+ 1
Prakash yes. You can get an error message 'cannot reference [thing] in a static context' and this is the reason. Static members do not belong to an instance so can only refer to the non-instance (static) members
28th Aug 2018, 8:51 AM
Dan Walker
Dan Walker - avatar
+ 5
oops language? What is that supposed to mean?
28th Aug 2018, 3:21 AM
hi user, #Have_Hope
hi user, #Have_Hope - avatar
+ 5
How about the "s"?
28th Aug 2018, 3:25 AM
hi user, #Have_Hope
hi user, #Have_Hope - avatar
+ 4
Which language?
28th Aug 2018, 3:15 AM
hi user, #Have_Hope
hi user, #Have_Hope - avatar
+ 2
A member function can operate on the state of an object, but a static method cannot. Static method is invoked on the class, with no reference to any particular instance, otherwise a method is invoked on an instance and can interact with that instance
28th Aug 2018, 6:30 AM
Dan Walker
Dan Walker - avatar
0
basically c#,but is it not the same for all oops language ?
28th Aug 2018, 3:18 AM
Prakash
Prakash - avatar
0
object oriented programming
28th Aug 2018, 3:23 AM
Prakash
Prakash - avatar
0
it'll be called as oops in short
28th Aug 2018, 3:26 AM
Prakash
Prakash - avatar
0
Dan Walker So what you mean by the way is ,you can only access the static member variables inside the static function ?
28th Aug 2018, 8:49 AM
Prakash
Prakash - avatar