+ 2

Why static is used in defining a function

1st Sep 2017, 12:39 PM
Dhanush Shetty
Dhanush Shetty - avatar
4 Answers
+ 2
if the function (method) is defined as a static it belongs to a class not to object.For calling this kind of methods you shoud not create an object.Acces specifier is class name not an object name.
1st Sep 2017, 12:57 PM
Highman
Highman - avatar
+ 2
but be aware, in C and C++ has the static modificator different meaning;)Only for full explenation;)
2nd Sep 2017, 8:07 PM
Highman
Highman - avatar
+ 1
A static member function can be called even if no objects of the class exist and the static functions are accessed using only the class name and the scope resolution operator : A static member function can only access static data member, other static member functions and any other functions from outside the class.
1st Sep 2017, 12:50 PM
Harsh
Harsh - avatar
0
how we write the accessing statement of a class name sum and static member function data??
2nd Sep 2017, 12:05 PM
Harsha Sanju
Harsha Sanju - avatar