Expected primary expression (inside constructor)

Can someone help me work out this error?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 guidedTour.cpp: In constructor 'GuidedTour::GuidedTour(std::string, std::string, double, double, Date, double, std::string)':
guidedTour.cpp:4: error: expected primary-expression before 'id'
guidedTour.cpp:4: error: expected primary-expression before 'description'
guidedTour.cpp:4: error: expected primary-expression before 'double'
guidedTour.cpp:4: error: expected primary-expression before 'double'

// SOURCE
 
#include "guidedTour.h"
 
GuidedTour::GuidedTour(string id, string description, double fee, double numBookings, Date theDate,
double maxNoTourists, string tourGuide) : Tour(string id, string description, double fee, double numBookings)
{
   this->id = id;
   this->fee = fee;
   this->numBookings = numBookings;
   this->theDate = theDate;
   this->maxNoTourists = maxNoTourists;
   this->tourGuide = tourGuide;
}
Um... why do you have an initialiser list and initialising the data inside the constructor? I might be able to help more if you give me your class declaration, but at a guess, this might fix it:

1
2
3
4
5
6
7
8
9
#include "guidedTour.h"

GuidedTour::GuidedTour(string _id, string _description, double _fee,
                       double _numBookings, Date _theDate,
                       double _maxNoTourists, string _tourGuide)
    : id(_id), description(_description), fee(_fee), numBookings(_numBookings),
      theDate(_theDate), maxNoTourists(_maxNoTourists), tourGuide(_tourGuide)
{
}


EDIT:
Are you also trying to initialise a struct "Tour"? You can add that to the initialiser list if you want...
Last edited on
Don't worry I fixed the problem thanks.
Topic archived. No new replies allowed.