架构x86_64: party::getArrival()的未定义符号

Undefined symbols for architecture x86_64: party::getArrival()

本文关键字:未定义 符号 party x86 架构 getArrival      更新时间:2023-10-16

我有一个名为party.hparty类的头文件:

#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

及其在party.cpp中的实现:

#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中构建,这样我就可以完成调试/编程我的项目,这是今晚到期。任何帮助都非常感谢!谢谢!

您没有在party.cpp文件中定义getArrival。您可能需要:

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