我有一項任務,必須爲我的函數使用不同的文件,而且我不必使用頭文件。問題是編譯器向我顯示了各種錯誤。所有的錯誤對我所有的功能都完全一樣。在不同文件中的函數定義中的結構參數
這是錯誤:
1> ------構建開始:項目:Asignacion 1,配置:調試的Win32 ------
1> SortCompany的.cpp
1> C:\用戶\伊曼紐爾\文件\視覺工作室2013 \項目\ asignacion 1 \ asignacion 1 \ sortcompany.cpp(1):錯誤C2065:Elemento的:未聲明的標識符
1 > c:\ users \ emanuel \ documents \ visual studio 2013 \ projects \ asignacion 1 \ asignacion 1 \ sortcompany.cpp(1):error C2146:syntax error:missing')'before'identifier'Dealer'
1> c :\ users \ emanuel \ documents \ visual studio 2013 \ projects \ asignacion 1 \ asignacion 1 \ sortcompany.cpp(1):error C2182:'SortCompany':非法使用類型'void'
1> c:\ users \ emanuel \ documents \ visual studio 2013 \ projects \ asignacion 1 \ asignacion 1 \ sortcompany.cpp(1):error C2059:syntax error:')'
1> c:\ users \ emanuel \ documents \ visual studio 2013 \ projects \ asignacion 1 \ asignacion 1 \ sortcompany.cpp(2):錯誤C2143:語法錯誤:缺少';'之前'{'
1> c:\ users \ emanuel \ documents \ visual studio 2013 \ projects \ asignacion 1 \ asignacion 1 \ sortcompany.cpp(2):error C2447:'{':missing function header(old式的正式名單?)
(同樣的錯誤如上的所有文件.....)
1>生成代碼... ==========構建:0成功,1失敗,0最新,0跳過==========
我有main.cpp這是主要文件(顯然)。主要調用「Menu.cpp」和菜單調用其他文件中的所有其他功能。
PD:Elemento的[]是一個結構
Menu.cpp代碼:
using namespace std;
//these functions are fine
void Closing(ifstream &, ofstream &);
void Opening(ifstream &, ofstream &);
//the problem is here with all these functions
void Registro(Elemento[], int &, ifstream &);
void InfoDealer(Elemento[], int, ofstream &);
void SortCompany(Elemento[], int);
void MayorVentas(Elemento[], int, ofstream &);
void MayorVentasPorMarca(Elemento[], int, ofstream &);
#include "Registro.cpp"
#include "InfoDealer.cpp"
#include "SortCompany.cpp"
#include "MayorVentas.cpp"
#include "MayorVentasPorMarca.cpp"
void Menu()
{
//code here...
}
Registro.cpp:
void Registro(Elemento Dealer[], int &Cantidad, ifstream &entrada)
{
//code here...
}
main.cpp中:(此文件是默認的,我不應該改變它。)
//include stuff
using namespace std;
const int MAXIMODEALERS = 20;
const int MAXIMOMODELOS = 6;
struct Detail
{
string ModelName;
int Sales;
};
typedef Detail Detalle;
struct Element
{
string CompanyName;
Detalle Modelo[MAXIMOMODELOS];
};
typedef Element Elemento;
Elemento Dealer[MAXIMODEALERS];
int Cantidad;
void Menu(void);
#include "Menu.cpp"
void Opening(ifstream &Entrada, ofstream &Salida)
{
//code
}
void Closing(ifstream &entrada, ofstream &salida)
{
//code
}
int main()
{
Menu();
return 0;
}
所有其餘的文件具有與Registro.cpp相同的結構
希望你能幫助我!如果你需要更多的細節,請提出要求。
你確定這是一個* C++ *過程中,而不是* C *課程? – crush
是C++ ......... – emanuel1337
只是在開玩笑:P – crush