我迷失了,并且用尽了我所知道的事情。我试图在我的主要调用一个函数,我不断得到一个未定义的引用错误(未定义引用'ParkingController :: parkingMenuControl()')。
我该如何解决这个问题?我试图将该调用重命名为该类,甚至尝试重命名该类,并且该类已经有效。以下是我的代码。提前感谢您的帮助。
ParkingConrtol.h
#ifndef PARKINGCONTROL_H_INCLUDED
#define PARKINGCONTROL_H_INCLUDED
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdlib>
using namespace std;
class ParkingController
{
public:
void parkingMenuControl();
int parkingOption;
private:
};
#endif
parkingControlMain.cpp
#include "parkingControl.h"
using namespace std;
ParkingController parkingMenuMain;
int main(){
cout << "Welcome, Would you like to view our menu for parking?"<< endl;
cout << "Enter 1 to view menu or 0 to leave." << endl;
cin>>parkingMenuMain.parkingOption;
if (parkingMenuMain.parkingOption == 0)
{
exit(-1);
}
else if (parkingMenuMain.parkingOption == 1)
{
parkingMenuMain.parkingMenuControl();
}
}
最后这是我的函数parkingControl.cpp
#include "parkingControl.h"
/*
This module sets up the menu for the parking controller.
In here one can view the drawer with the money stored in
it and select a parking gate to enter from.
*/
using namespace std;
ParkingController parkingControlMenu;
void ParkingController::parkingMenuControl()
{
//Doing some function
}