2013-04-22 73 views
-1

我對party類稱爲party.h一個頭文件:在party.cpp未定義的符號:黨:: getArrival()

#ifndef party_h 
#define party_h 

#include <iostream> 

class party{ 
private: 
    int people; 
    int waitTime; 
    bool waiting; 
    int arrival; 

public: 
    party(); 
    party(int, int); 
    int getPeople(); 
    void setPeople(int); 
    bool isWaiting(); 
    void setWaiting(bool); 
    void setWaitTime(int); 
    int getwaitTime(); 
    void setArrival(int); 
    int getArrival(); 
    int getTotalTime(int); 
    void decrement(); 
}; 

#endif 

及其實施:

#include "party.h" 

party::party(){} 

party::party(int numPeople, int a){ 
    people = numPeople; 
    arrival = a; 
} 
int party::getPeople(){ 
    return people; 
} 

void party::setPeople(int p){ 
    people = p; 
} 

bool party::isWaiting(){ 
    return waiting; 
} 

void party::setWaiting(bool w){ 
    waiting = w; 
} 

void party::setWaitTime(int t){ 
     waitTime = t; 
} 

int party::getwaitTime(){ 
    return waitTime; 
} 

void party::setArrival(int a){ 
    arrival =a; 
} 

int party::getTotalTime(int current){ 
    return (current-arrival); 
} 

每當我建該項目我收到下面的錯誤信息,

Ld /Users/shade/Library/Developer/Xcode/DerivedData/ResSim-fvkhqxhiupiizxgffxqgoxgolsmv/Build/Products/Debug/ResSim normal x86_64 cd /Users/shade/Dropbox/School/Gwinnett_Tech/CIST_2362/final/ResSim setenv MACOSX_DEPLOYMENT_TARGET 10.8 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -L/Users/shade/Library/Developer/Xcode/DerivedData/ResSim-fvkhqxhiupiizxgffxqgoxgolsmv/Build/Products/Debug -F/Users/shade/Library/Developer/Xcode/DerivedData/ResSim-fvkhqxhiupiizxgffxqgoxgolsmv/Build/Products/Debug -filelist /Users/shade/Library/Developer/Xcode/DerivedData/ResSim-fvkhqxhiupiizxgffxqgoxgolsmv/Build/Intermediates/ResSim.build/Debug/ResSim.build/Objects-normal/x86_64/ResSim.LinkFileList -mmacosx-version-min=10.8 -stdlib=libstdc++ -o /Users/shade/Library/Developer/Xcode/DerivedData/ResSim-fvkhqxhiupiizxgffxqgoxgolsmv/Build/Products/Debug/ResSim 
Undefined symbols for architecture x86_64: "party::getArrival()", referenced from: restaurant::startSim() in restaurant.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) 
"party::getArrival()", referenced from: Restaurant::startSim() in restaurant.o Symbol(s) not found for architecture x86_64 Linker command failed with exit code 1 (use -v to see invocation) 

這是一個新的錯誤消息,因爲它在今天早上/本週末在Visual Studio中工作。但是自那時以來,我已經改變了大量的代碼,要點中的代碼已經更新,並且正在與我一起工作。我目前正試圖讓它在xcode中生成,這樣我就可以完成我今晚計劃的項目的調試/編程。任何幫助是極大的讚賞!謝謝!

+1

未來,請在您的問題中發佈相關代碼,而不是鏈接到它。它可能會幫助你首先創建一個[SSCCE](http://sscce.org/)。 – 2013-04-22 22:07:26

回答

2

您沒有在您的party.cpp文件中定義getArrival。您可能想要:

int party::getArrival(){ 
    return arrival; 
}