In C language if the keyword static appears before any function declaration, it means that the function will now have a file scope or private scope. That is, the static function can be accessed only in the file that declares it. This means, the function is not known outside its own file. Another file may use the same name for a different function.

However in C++ the meaning of static is not the same. Here static member functions are those functions that can be called without any object creation. Scope resolution operator is used to call a static member function.

Example:

class C
{
  public:
  static void static_function(void)
  {
  }
};
void main(int argc, char *argv[])
{
  C::static_function();/*Object not needed*/
}

About our authors: Team EQA

You have viewed 1 page out of 62. Your C++ learning is 0.00% complete. Login to check your learning progress.

#