本人在main这个源文件中定义了一个函数,希望在另一个文件中引用这个函数,但运行时显示以下报错,请问要怎么解决?
这是定义函数的代码:
#include
void Log(const char* message)
{
std::cout<< message <int main()
{
Log("hello world" );
std::cin.get();
}
这是引用的代码:
void Log(const char* message)
void InitLog()
{
Log("Initializing Log");
}
这是报错的显示:
是不是log.cpp那个void Log函数定义后面少了分号?
另外好的习惯是头文件声明,主体文件定义。然后应该在main.cpp调用其他文件的定义,不要在其他文件调用main.cpp里的函数,被调用函数放到其他文件,不要放main.cpp里面