naive231
naive231

Reputation: 1380

static function definition in header

In a header xxx.h:

static int yyy();
int yyy()
{
    return 0;
}

If I include xxx.h into a cpp file, is yyy() still a static function?

Upvotes: 1

Views: 2277

Answers (1)

Dialecticus
Dialecticus

Reputation: 16779

Yes, still static. Every compilation unit (.cpp file) will have its own version of yyy.

Compiler does not "see" header files. They are gone in pre-processing stage, where each #include is replaced with the text of the file contents of that #include, and the compiler will see only one very long stream of characters.

Upvotes: 5

Related Questions