0

Static is used in classes to say that variable or function is the same fo all class objects, but we can create static function or variable outside class, and sometimes it fix errors, what diference between static function and not static outside class.

For example:

static int foo1()
{
return 1;
}
int foo2()
{
return 1;
}
int main()
{
return 0;
}

what diference between foo1 and foo2?

Olexy
  • 324
  • 1
  • 9

1 Answers1

1

Static functions are only visible in the specific source file, while as foo2() could be visible in other files, too. If the declaration gets provided, through a header file, for example, you can call the non-static funtion from somewhere else

RoQuOTriX
  • 2,871
  • 14
  • 25