Hi guys,
I am having an issue with this parking lot simulation
my code is not accepting the police officer class as a friend in the parked car class.
This is the error I am getting
Error 1 error C2065: 'ParkedCar' : undeclared identifier d:\libraries\my documents\visual studio 2013\projects\project 6\project 6\policeofficer.h 32
Error 3 error C2245: non-existent member function 'PoliceOfficer::checkTime' specified as friend (member function signature does not match any overload) d:\libraries\my documents\visual studio 2013\projects\project 6\project 6\parkedcar.h 40
ParkedCar.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
#ifndef PARKEDCAR_H
#define PARKEDCAR_H
#include <string>
#include <vector>
#include "PoliceOfficer.h"
using namespace std;
class ParkedCar
{
private:
string make;
string model;
string color;
string license;
string pTime;
static int carCount;
public:
ParkedCar ();
~ParkedCar ();
// Mutator functions
void setMake (string);
void setModel (string);
void setColor (string);
void setLicense (string);
void setPTime (string);
void addCars ();
// Accessor functions
string getLicenseNumber () const;
string getModel () const;
string getColor () const;
string getMake () const;
string getPTime () const;
int getCars () const;
friend void PoliceOfficer::checkTime (vector<ParkedCar> &, vector<ParkedCar> &);
};
#endif
| |
PoliceOfficer.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
#ifndef POLICEOFFICER_H
#define POLICEOFFICER_H
#include <string>
#include <vector>
using namespace std;
class PoliceOfficer
{
private:
string clockIn;
string officerName;
string badgeNum;
string meterTime;
static int policeCount;
public:
PoliceOfficer ();
~PoliceOfficer ();
// Mutator Functions
void setTime (string);
void setName (string);
void setBadgeNum (string);
void countPolice ();
// Accessor functions
string getClockIn () const;
string getName () const;
string getBadgeNum () const;
void checkTime (vector<ParkedCar> &, vector<ParkedCar> &);
};
#endif
| |
I am also getting errors with those vectors
Error 6 error C2923: 'std::vector' : 'ParkedCar' is not a valid template type argument for parameter '_Ty' d:\libraries\my documents\visual studio 2013\projects\project 6\project 6\policeofficer.h 32
Error 11 error C2664: 'void PoliceOfficer::checkTime(std::vector &,std::vector &)' : cannot convert argument 1 from 'std::vector<ParkedCar,std::allocator<_Ty>>' to 'std::vector &' d:\libraries\my documents\visual studio 2013\projects\project 6\project 6\jamescombscs1337project6.cpp 110
I am lost on how to format my logic correctly.
I am trying to keep the code minimal so let me know if you want to see the .cpp's
Even if I include the ParkedCar header in PoliceOfficer.h it does not work. It is saying that ParkedCar is an undeclared identifier in the vectors as well.
As well friend void PoliceOfficer::checkTime (vector<ParkedCar> &, vector<ParkedCar> &);