I get the above error when I use this code.
//Programming Assignment 1 #include <iostream> #include <fstream> #include <string> using namespace std; //Function Prototypes void getname(ofstream); //void Evaluate_holesterol(ofstream); //void Evaluate_BMI(ofstream); //void Evaluate_bloodpressure(ofstream); int main() { //Open output file ofstream pfile; pfile.open("Profile.txt"); getname(pfile); //Evaluate_holesterol(pfile); //Evaluate_BMI(pfile); //Evaluate_bloodpressure(pfile); //pfile.close(); system("pause"); return 0; } //Function to get patient's name void getname(ofstream &pfile) { string name; int age; cout<<"What is the patient's full name (middle initial included)?"; getline(cin, name); cout<<endl<<"What is the patient's age?"; cin>>age; string line = "Patient's Name: "; string ageline = "Patient's Age: "; pfile<<line+name<<endl; pfile<<age<<endl; } I've checked my functions and arguments and I don't see any function that its can be confusing its arguments with anywhere else. Apologies in advance if its something simple and I just didn't see it.
getnamedoesn't have a&, but your definition does.main()you have a declarationvoid getname(ofstream). Aftermain()you have a definition ofvoid getname(ofstream &pfile). Note the missing&in the first. That's the problem in your code - why it gives that specific error with your compiler, I don't know (astd::ofstreamcannot be passed by value, so the first declaration would not compile).ofstream pfile; pfile.open(“Profile.txt”);toofstream pfile(“Profile.txt”);.