【发布时间】:2012-05-11 12:21:25
【问题描述】:
我已经为主要功能和菜单功能实现了客户、DVD、收据、类和 2 个文件,我包含了所有 .h 文件,但是当我使用菜单功能中的一个功能时,它不起作用,并说功能未定义。我想将其写入一个单独的 .cpp 文件,该文件称为 main,它是我的应用程序的驱动程序。
这是我的代码:
#ifndef CUSTOMER_H
#include "Customer.h"
#endif
#ifndef DVD_H
#include "DVD.h"
#endif
#ifndef MAIN_FUNC_H
#include "MainFunctions.h"
#endif
#ifndef MENU_FUNC_H
#include "MenuFunctions.h"
#endif
#ifndef RECEIPT_H
#include "Receipt.h"
#endif
using namespace std;
int main () {
intro();
return 0;
}
错误是:
错误 1 错误 C2129:已声明静态函数 'void intro(void)' 但 未定义 c:\program files (x86)\microsoft visual studio 10.0\vc\include\xmemory 186 1 DVD_App
即使函数intro()在MenuFunctions.h文件中定义,并在MenuFunctions.cpp中实现
注意:这两个文件 MenuFunctions 和 MainFunctions 中没有类,只是静态函数 我也试过没有包含警卫,但还是没用
【问题讨论】:
-
从 intro() 声明中删除
static -
它起作用了 o_O 如果我删除了静电为什么它会起作用?