Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

forward declare static function c++

Tags:

c++

I want to forward declare a static member function of a class in another file. What I WANT to do looks like this:

BigMassiveHeader.h:

class foo
{
    static void init_foos();
}

Main.cpp:

class foo;
void foo::init_foos();
int main(char** argv, int argc)
{
    foo::init_foos()
}

This fails out with "error C2027: use of undefined type 'foo'"

Is there a way to accomplish what I want to do with out making init_foos a free function, or including BigMassiveHeader.h? (BigMassiveHeader.h is noticeably effecting compile time, and is included everywhere.)

like image 626
Matthew Scouten Avatar asked Apr 16 '10 19:04

Matthew Scouten


1 Answers

You cannot forward declare members of a class, regardless of whether they are static or not.

like image 198
David Rodríguez - dribeas Avatar answered Oct 05 '22 01:10

David Rodríguez - dribeas