Static member function – C++ tutorial

C++ tutorials >> Static Member Function in C++


Static data types can be accessed without instantiation of the class in C++. This is applicable for static functions also. The static member functions are accessible even when the class is not instantiated.

The Properties of static member function in C++ :

  • can be called, even when a class is not instantiated
  • cannot be declared as virtual.
  • cannot access THIS pointer.
  • Can access only – static member data, static member functions, data and functions outside the class.

The differences between a static member function and non-static member functions are as follows.

    • A “static member function” can access only “static member data, static member functions and data and functions outside the class”. A non-static member function can access all of the above including the static data member.
    • A static member function property : can be called, even when a class is not instantiated.

Non-static member function property : can be called only after instantiating the class in an object.

  • A static member function property : cannot be declared virtual.
    Non-static member function property : can be declared as virtual
  • A static member function property : Cannot have access to the ‘this’ pointer of the class.
  • For loops in C , a tutorial

For C++ tutors, online tutors & C++ teacher in Kolkata visit this page

Save

Save

Save

Author: Online Computer Teacher

OCT Group Kolkata conduct private coaching on Computer science and applications based subjects in Kolkata. Call 9163111390 to get a Computer science teacher- on css3, HTML5, JavaScript, jQuery in Kolkata. Also learn how to program Java C C++ PHP MySQL & responsive web designing, CSS3 HTML5 LESS SASS and many other topics related to website designing.