更新时间:2022-12-24 09:21:56
在C ++中,全局/命名空间范围内的 static
表示该功能/变量仅在定义该功能/变量的翻译单元中使用,不在其他翻译单位中.
In C++, static
at global/namespace scope means the function/variable is only used in the translation unit where it is defined, not in other translation units.
在这里,您尝试使用的静态函数与定义其定义单元( File.cpp
)不同的转换单元( Main.cpp
).
Here you are trying to use a static function from a different translation unit (Main.cpp
) than the one in which it is defined (File.cpp
).
删除 static
,它应该可以正常工作.
Remove the static
and it should work fine.