Default argument not at end of parameter list.

Sep 22, 2015 at 6:04am
I am trying to create a header file for a Patient class. Where I am having trouble in the first place is creating the default constructor. Whenever I put the Date private member(from a different header file that has Date and three private variables that include a day, month, and year numbers) I get an error saying "Default argument not at end of parameter list". Am i declaring that part wrong?

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
  #ifndef PATIENT1_H
#define PATIENT1_H
#include <iostream>
#include "date.h"
#include <string>

using namespace std;


class Patient{

	struct procedure{
		Date dateOfProcedure;
		int procedureID;
		int procedureProviderID;

	};

public:
	Patient(int id = 0, const char* fn = "John", const char* ln = "Doe", Date bday ); //Put in default values 
	// just as in Date class
	//Use the set functions so input values are checked  
	~Patient();
	Patient & setID(int);
	Patient & setFirstName(const char *); //check if length of name string is <  15
	Patient & setLastName(const char *);  //check if length of name string is < 15
	Patient & setBirthDate(Date);
	Patient & setPrimaryDoctorID(int);

	int getID();
	const char * getFirstName();
	const char * getLastName();
	Date getBirthDate();
	int getPrimaryDoctorID();

	bool enterProcedure(Date procedureDate, int procedureID, int procedureProviderID);
	void printAllProcedures();

private:
	int ID;
	char firstName[15];
	char lastName[15];
	Date  birthdate;
	int primaryDoctorID;  //Add
	procedure record[500];
	int currentCountOfProcedures; 

};

#endif 


In the Date class header the default constructor looks like this
 
	Date(int m = 1, int d = 1, int y = 1900);
Last edited on Sep 22, 2015 at 6:06am
Sep 22, 2015 at 6:12am
It's complaining because bday doesn't have a default argument. It would be useless to have default arguments if the last one didn't have one because there is no way you can leave out the middle arguments without leaving out the last argument, but you can't leave out the last argument if it doesn't have a default argument.
Last edited on Sep 22, 2015 at 6:14am
Sep 22, 2015 at 6:19am
I'm honestly pretty lost here. I tried this and I am still getting the same error.
1
2
Patient(int id = 0, const char* fn = "John", const char* ln = "Doe", 
       Date bDay(int , int , int), int docID = 0, procedure rec, int count = 0 );

Last edited on Sep 22, 2015 at 6:19am
Sep 22, 2015 at 9:15am
To specify a default argument for bday you do something like this
 
Date bday = Date(0, 1, 2)
or this:
 
Date bday = {0, 1, 2}
Last edited on Sep 22, 2015 at 9:16am
Sep 22, 2015 at 10:46am
Patient(int id = 0, const char* fn = "John", const char* ln = "Doe", Date bday = Date());
Topic archived. No new replies allowed.