0

I am lost and ran out of things to try that I know. I am trying to call a function in my main and I keep getting an undefined reference error (undefined reference to 'ParkingController::parkingMenuControl()').

How can I solve this issue? I have tried to rename that call to the class and even tried to rename the class and non of that has worked. Below is my code. Thank you in advance for help.

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();
  }
}

and lastly here is my function 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
}
MPNation
  • 179
  • 2
  • 4
  • 12
  • 1
    Can you post the command you use to compile? – clcto Nov 18 '14 at 22:43
  • I *strongly* suspect your question is [related to this one](http://stackoverflow.com/questions/13188260/undefined-reference-to) (and perhaps a few hundred others if you search for "undefined reference" for c++ on this site). – WhozCraig Nov 18 '14 at 22:44
  • @clcto I am compiling inside of codeblocks. – MPNation Nov 18 '14 at 22:46
  • @MPNation CodeBlocks will emit the compile and link lines in the output log window during a build. – WhozCraig Nov 18 '14 at 22:49
  • I just built your code locally and didn't get any errors at all :( `clang++ main.cpp parkingControl.cpp` – Neil Nov 18 '14 at 22:53
  • It seems like your a missing an object file parkingControl.obj in the linking – Jens Munk Nov 18 '14 at 23:03

0 Answers0