1) static member functions do not have this pointer.
For example following program fails in compilation with error “`this’ is unavailable for static member functions “
2) A static member function cannot be virtual (See this G-Fact)
3) Member function declarations with the same name and the name parameter-type-list cannot be overloaded if any of them is a static member function declaration.
For example, following program fails in compilation with error “‘void Test::fun()’ and `static void Test::fun()’ cannot be overloaded “
4) A static member function can not be declared const, volatile, or const volatile.
For example, following program fails in compilation with error “static member function `static void Test::fun()’ cannot have `const’ method qualifier ”
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Rated as one of the most sought after skills in the industry, own the basics of coding with our C++ STL Course and master the very concepts by intense problem-solving.
- Some Interesting facts about default arguments in C++
- Count the number of objects using Static member function
- Interesting facts about switch statement in C
- C++ bitset interesting facts
- Interesting facts about data-types and modifiers in C/C++
- Interesting Facts about C++
- Const member functions in C++
- C/C++ Ternary Operator - Some Interesting Observations
- Difference between static and non-static method in Java
- Difference between static and non-static variables in Java
- Internal static variable vs. External static variable with Examples in C
- Understanding storage of static methods and static variables in Java
- Why non-static variable cannot be referenced from a static method in Java
- Understanding "static" in "public static void main" in Java
- List in C++ | Set 2 (Some Useful Functions)
- Can static functions be virtual in C++?
- Can we access private data members of a class without using a member or a friend function?
- Can C++ reference member be declared without being initialized with declaration?
- C++ programming and STL facts
- Facts and Question related to Style of writing programs in C/C++
Improved By : bhuvanchandra825