What is the purpose of static member functions in a class?

danibecse
Recommended Answers
Jump to PostStatic functions are generally used when you have static data members in a class and you want to be able to acess the static data. You have to have a satic function to acess static data since it is seperate from the objects of that class.
Jump to PostWhen you have a member variable which value you want to share among all instances of a class, you declare it as static. In order to access that member with a method, the method also has to be declared static.
#include <iostream> class MyClass { static int …
Jump to PostWhat is the purpose of static member functions in a class?
Well, others have already pointed out one kind of purpose for static member functions. But there are many others too. In other words, there are many "tricks" that rely on a static member function(s). So, it's pretty …
All 9 Replies
NathanOliver
429
Veteran Poster
Featured Poster
rstralberg
0
Newbie Poster
danibecse
commented:
Any other use it has......?
+0
umesh314
-3
Newbie Poster
Lucaci Andrew
140
Za s|n

danibecse
Daniel BE
0
Newbie Poster
Daniel BE
0
Newbie Poster
mike_2000_17
2,669
21st Century Viking
Team Colleague
Featured Poster
NathanOliver
429
Veteran Poster
Featured Poster
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.