我已經爲主要功能和菜單功能實現了Customer,DVD,Receipt,classes和2個文件,我包含了所有.h文件,但是當我從菜單功能中使用函數時,它不工作,並說功能沒有定義。我想寫一個獨立的.cpp文件,它被稱爲main,它是我的應用程序的驅動程序。來自其他C++文件的訪問方法
這是我的代碼:
#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介紹(無效)' 聲明但 沒有定義C:\程序文件(86)\微軟的Visual Studio 10.0 \ VC \包括\ xmemory 186 1 DVD_App
即使函數intro()
在MenuFunctions.h
文件中定義,並實施了MenuFunctions.cpp
注:2檔,MenuFunctions和MainFunctions不要在他們班,只是靜態函數 我也試了一下,而不包括警衛,再沒有工作
移除介紹()聲明 – nothrow
它的工作O_O 了'static'爲什麼它工作,如果我去除靜電? –
aizen92,看到我的回答 – nothrow