-1

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

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

4

1 回答 1

2

您没有getArrivalparty.cpp文件中定义。你可能想要:

int party::getArrival(){
    return arrival;
}
于 2013-04-22T22:04:32.727 回答