0
我似乎遇到了一個奇怪的問題,以前沒有回答過的未聲明的標識符問題似乎涵蓋了它。對不起,如果我忽略了一個。未聲明的標識符問題
我正在用C++構建一個類文件,並且在我注意到在我的聲明結尾處沒有包括一個右括號之前,幾乎完成了它。但是,一旦我添加了括號和分號,我調用兩個特定變量的所有實例都會返回「未聲明的標識符」報告。
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
class FerryBoat
{
//Variables
private:
int numOfPorts;
int startingPort;
int destinationPort;
int maximumAutos;
int currentPort;
int currentAutos;
//Methods
public:
FerryBoat(int, int, int); //build up
void moveBoat(int); //Push the ferry to it's designated station
int getDestinationPort(); //returns destination port
int getRandNum(int); //generates randomized numbers for the program
void loadAutos(int); //Loads cars on the port limited by the number of cars at that port. The port then has those cars subtracted from their total
void unloadAutos(); //Unloads cars on board
int getCurrentAutos(); //Returns the current number of cars on the ferry
int getMaxCapacity(); //returns the max number of autos able to board
int getStartingPort(); //Returns our start position
int getNumPorts(); //returns the number of ports featured
int getCurrentPort(); //returns our current port
};
FerryBoat::FerryBoat(int ports, int capacity, int start)
{
numOfPorts = ports;
startingPort = start;
maximumAutos = capacity;
currentPort = startingPort;
destinationPort = startingPort;
currentAutos = 0;
}
void moveBoat(int nextStop)
{
destinationPort = nextStop;
cout<<"There are currently "<< currentAutos <<" autos loaded on the ferry."<<endl;
cout<<"We are now leaving port "<<currentPort<<" for port "<<destinationPort<<"."<<endl;
cout<<"[Movement in Progress]"<<endl;
currentPort = destinationPort;
cout<<"We have reached port "<<currentPort<<endl;
}
沒有其他的似乎,他們都在同一地區宣佈。 它是特別的「destinationPort」和「currentAutos」返回的問題,並將其與以前的代碼工作似乎沒有指出任何明顯的問題。我忽略了一些微小的東西,或者我在某處旅行並犯了一個錯誤?
如果已經得到解答,再次感謝您和appologies!
'moveBoat'不是成員函數.. 。 –