header files problem

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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef POLICE_H
#define POLICE
#include <iostream>
#include <cstring>
#include <string>
#include "Ticket.h"
#include "ParkedCar.h"
#include "ParkingMeter.h"

using namespace std;

class Police
{

private:
   string policeName, pBadgeNum;
   int parkedTime, timePurchased;
   double car_min_hr, min_hr, feeAmount;
   ParkedCar parked;        //Parked Class
   ParkingMeter prkmeter;   //Parking meter class

public:
   // Constructor
   Police(string a, string b)
      {
         policeName = a;
         pBadgeNum  = b;

      }

  void checkCar()
  {
        parked.input("","","","",0);
        parkedTime = parked.getParkedTime();
        car_min_hr = parkedTime / 60.0;
        timePurchased = prkmeter.getPurchasedTime();
        min_hr = timePurchased / 60.0;

        if (car_min_hr > min_hr)
           calc();
            Ticket ticket(string make, string model, string color, string tag, string policeName, string pBadgeNum, double feeAmount);
            ticket.print();
         }

   void calc()
   {
       double temp;

       temp = car_min_hr - min_hr;
            if (temp > 1)
                feeAmount = (temp * 10) + 25;
            else
                feeAmount = 25;
   }
};

#endif // POLICE_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
#ifndef TICKET_H
#define TICKET_H
#include <string>
#include <iostream>
using namespace std;

class Ticket
{
    public:
        Ticket(string a, string b, string c, string d, string e, string f, double g)
        {
            make = a;
            model = b;
            color = c;
            tag = d;
            policeName = e;
            pBadgeNum = f;
            feeAmount = g;
        }
    private:
        string make, model, color, tag, policeName, pBadgeNum;
        double feeAmount;

    void print() const
    {
        cout<<"Car Make: "<<make<<endl;
        cout<<"Car Model: "<<model<<endl;
        cout<<"Car Color: "<<color<<endl;
        cout<<"License Plate Number: "<<tag<<endl;
        cout<<"Police Name: "<<policeName<<endl;
        cout<<"Badge Number: "<<pBadgeNum<<endl;
        cout<<"Fee Amount: "<<feeAmount<<endl;
    }
};

#endif // TICKET_H 



ok so here's my code for the Police.h and Ticket.h header files. I get an error saying error: request for member "print" in "ticket" which is non-class type 'Ticket(std::string....

Basically I'm trying to get ticket.h to print out the information if only the parked minutes are more than purchased minutes. This is a parking ticket simulator. If you need me to provide the code for the other two header files and the main.cpp let me know. Thanks for helping.
At least post the entire error, it is useful to someone that knows how to read them.

That said, I'm guessing the error says something like it is inaccessible, because it is private.
in member function void Police::checkCar()':


that's it for the error
Make print public, problem solved.
I did that and unfortunately I still get the same error message.
No, I know hy it's wrong! remove the type specifiers in the construction Ticket ticket(/*all that stuff goes here*/);. This way you are just making a new function!
What viliml said is correct, I overlooked that (answering from my phone these forums mess with readily hah)
Topic archived. No new replies allowed.