Apologies for not being more specific in the OP.
From the header file the constructor is initialized as such:
1 2 3 4
|
PatientDemographicInformation(String medicalRecordNo, String firstName,
char middleInitial, String lastName, String streetAddress1, String streetAddress2,
String city, String state, String zip5,String zip4, String homeAreaCode, String homePhoneNo,
char gender, int dateOfBirth);
|
The test program is using the current values in the constructor...:
1 2
|
PatientDemographicInformation smith("123456789", "Robert", 'A', "Smith", "CS Department, Building #4, Room #403",
"101 West End Boulevard", "Pittsburgh", "PA", "15224", "3899", "550", "7400586", 'M', 01011967);
|
...and printing this information via the following function:
smith.printPatientDemographicInformation();
Here's the full function from the header file:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
void PatientDemographicInformation::printPatientDemographicInformation( )
{
cout << "----------------------PATIENT INFORMATION----------------------" << endl;
cout << "Medical Record No.: " << getPatientMedicalRecordNo( ) << endl;
cout << " Patient's Name: " << getPatientName( ) << endl;
cout << " Address: "; printPatientAddress( );
cout << setw(33) << getPatientPhoneNumber( );
cout << endl << endl;
cout << "Gender: " << getPatientGender( );
cout << " Date of Birth: "; getPatientDateOfBirth( );
cout << " Age: " << getPatientAge( ) << endl;
cout << "---------------------------------------------------------------" << endl;
}
|
The error I receive when compiling is: "error C2041: illegal digit '9' for base '8'"
I have to use the int entered as 01011967 and output it as MM/DD/YYYY using the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
int birthMonth;
int birthDay;
int birthYear;
birthMonth = (patientDateOfBirth / 1000000);
birthDay = ((patientDateOfBirth % 1000000) / 10000);
birthYear = (patientDateOfBirth % 10000);
if(birthMonth < 10)
{
cout << '0' << birthMonth << "/" << birthDay << "/" << birthYear;
}
else
{
cout << birthMonth << "/" << birthDay << "/" << birthYear;
|
Currently I'm leaving the lead zero out of the constructor (1011967) and it works flawlessly (you'll notice the workaround I have for months less than 10 in the previous snippet is to pad with a zero) however my instructor informed me that it would be incorrect and that there is another way.
I understand what an octal is and I also understand that generally the leading zero is not significant, but in this particular scenario I need to keep the zero as part of the month as it's a required part of my assignment.
I'm not looking for someone to do this for me, I just need to be pointed in the right direction.
Thank you.