我提出了在報頭中的自己的類型:C++未定義參照XXX在功能XXX
typedef int OperationId;
struct operation{
OperationId id;
JobId assignedJob;
MachineType machineType;
double earning;
std::vector<operation> operationPredecessors_;
std::vector<operation>::iterator oPredecessorsIterator;
std::vector<operation> operationSuccessors_;
std::vector<operation>::iterator oSuccessorsIterator;
double processingTime;
std::vector<Machine> operationMachines_;
std::vector<Machine>::iterator oMachinesIterator;
};
它使用其他的自定義類型。 現在我自己做了一些函數來創建操作,因爲我不希望所有與每一個操作的時間寫很多代碼:
operation createOperation ( operation o,
OperationId id,
MachineType type,
double earning,
double processingTime);
,並在在.cpp:
operation createOperation (operation o,
OperationId id,
MachineType type,
double earning,
double processingTime){
o.id = id;
o.machineType = type;
o.earning = earning;
o.processingTime = processingTime;
return o;
}
現在我調用與cunction:
OperationId id;
operation oSzero;
id = 0;
oSzero = createOperation(oSzero,id,INCOMING_GOODS,0,20);
它給了我下面的錯誤:
undefined reference to Schedule::createOperation(operation, int, MachineType, double, double)'
有人知道爲什麼嗎?我使用make作爲編譯器。它的功能完美無缺,並且:
oSzero.id = 0;
oSzero.MachineType = INCOMING_GOODS;
....
等主要直接。
什麼是'Schedule'? – Jarod42
順便提一下,'createOperation'可能是'operation'的構造函數(當你標記你的Q C++時)。 – Jarod42
日程安排是一門課程。然而,我在類之外定義了操作,因爲我在其他類中也使用它,並且希望將它用於全局。然而,我在調用createOperation的函數是Schedule的一部分。 – aratai