向前声明静态函数c ++ [英] forward declare static function c++

查看:243
本文介绍了向前声明静态函数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:

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()
}

这会失败,出现错误C2027:使用未定义类型'foo'

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

完成我想做什么使init_foos一个自由的功能,或包括BigMassiveHeader.h? (BigMassiveHeader.h显着影响编译时间,并且随处可见。)

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.)

推荐答案

不论它们是否静止。

这篇关于向前声明静态函数c ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆