error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'void' (or there is no acceptable conversion)
Hi, I have been searching all over and just can't get this problem resolved. Everyone says to include the <string> header file but I have. I have tried to compile this in multiple versios of Visual Studio( 97,08,10) I have done all I can think of and asked some friends but nobody knows. The problem I have is in a header file and anytime I try to output anything from a void function I get this error. It is not complete and includes unfinisshed funtions but can't continue intil this is fixed. Here is the header file:
// This header file maintains basic information about the patient. It includes the patient's name and patient's demographic location.
// Returns the patient's medical record number. If the patientMedicalRecordNo is black send a message to the screen and exit(1).
string getPatientMedicalRecordNo();
// Returns the patient's first name a space middle initial a space then the last neme.
string getPatientName();
// Returns the patient's state in all capital letters.
string getPatientState();
// Returns the patient's street address line 1, then on the next line city, a comma then a space and the state(capital letters),
// then 2 spaces zip5, then a dash, then zip4.
void printPatientAddress();
// Returns the patient's home area code enclosed in parenthesis, then the home phone number with a dash between the exchange and the number
string getPatientPhoneNumber();
// Returns the patient's gender description. "F" or "f" for Female and "M" or "m" for Male
string getPatientGender();
// Returns the patient's date of birth with dashes.
void printPatientDateOfBirth();
// Returns the patient's age.(Based on date of birth)
int getPatientAge();
/* Prints the patient demographic information.
* Medical Record No.: XXXXXXXXX-XX
* Patient's Name: (First Middle and Last Name)
* Address: (Address Line 1)
* (Address Line 2)
* (CIty State and Zip)
* (Phone Number)
Gender: X - Gender Description Date of Birth: XX/XX?XXXX Age: XXX */
void printPatientDemographicInformation();
};
// The Constructor initializes all objects of the patient
PatientDemographicInformation::PatientDemographicInformation(string medicalNo, string fName, char middleI, string lName, string address1, string address2, string city, string state, string zip5, string zip4, string areaCode, string phoneNo, char gender, int dateOfBirth)
{
patientMedicalRecordNo = medicalNo;
patientFirstName = fName;
patientMiddleInitial = middleI;
patientLastName = lName;
patientStreetAddress1 = address1;
patientStreetAddress2 = address2;
patientCity = city;
patientState = state;
patientZip5 = zip5;
patientZip4 = zip4;
patientHomeAreaCode = areaCode;
patientHomePhoneNo = phoneNo;
patientGender = gender;
patientDateOfBirth = dateOfBirth;
}
// Returns the patient's medical record number. If the patientMedicalRecordNo is black send a message to the screen and exit(1).
string PatientDemographicInformation::getPatientMedicalRecordNo()
{
if(patientMedicalRecordNo == "")
{
cerr << "No record of Patient.";
exit(1);
}
return patientMedicalRecordNo;
}
// Returns the patient's first name a space middle initial a space then the last neme.
string PatientDemographicInformation::getPatientName()
{
return patientFirstName + " " + patientMiddleInitial + " " + patientLastName;
}
// Returns the patients's state in all capital letters.
string PatientDemographicInformation::getPatientState()
{
// Function which cycles each position and changes the character to uppercase
for(unsigned int i=0; i < patientState.length(); i++)
{
patientState[i] = toupper(patientState[i]);
}
return patientState;
}
// Returns the persons address in a letter style format
void PatientDemographicInformation::printPatientAddress()
{
cout << patientStreetAddress1 << endl << patientStreetAddress2 << endl << patientCity << ", " << getPatientState() << " " << patientZip5 << "-" << patientZip4 << endl;
}
// Returns the patient's home area code enclosed in parenthesis, then the home phone number with a dash (570)740-0586
string PatientDemographicInformation::getPatientPhoneNumber()
{
//string areaCode;
//string phoneNumber;
//areaCode = "(" << patientHomeAreaCode << ")";
//char num[5];
//int i;
//for(i=0;i<=3;i++)
//{
// num[i]= patientHomePhoneNo.length;
//}
// Returns the patient's gender description. F for Female
string PatientDemographicInformation::getPatientGender()
{
string gender;
switch(patientGender)
{
case 'f':
case 'F': gender = "Female"; break;
case 'm':
case 'M':gender = "Male"; break;
default:
cerr << " The Gender isn't M/F";
exit(1);
}
return gender;
}
// Returns the patients's date of bitch with dashes.
void PatientDemographicInformation::printPatientDateOfBirth()
{
friend int month;
friend int day;
friend int year;
month = (date / 1000000.00);
day = ((date / 1000000.00)-month) * 100;
year = ((((date / 1000000.00)-month) * 100)-day) * 10000;
cout << month << "/" << day << "/" << year;
}
// Returns the Patient's age.Calculated from the Birth-Date
int PatientDemographicInformation::getPatientAge()
{
return 0;
}
****The program is in another file but only calls the functions to test them first I thought it could be in this but I comment out the calling and it takes me back to the header file. Any help would be greatly appreciated.
You have defined printPatientDateofBirth() as returning void; make it return a string instead, making sure to have it return the data instead of just cout'ing it.
EDIT: Looked at your post a bit more... You can't cout a void function. It just doesn't work. Just call the function normally as it already does a cout inside of itself to display the information. Though I would still recommend doing what I suggested above.