hello everyone,
I'm working on this project about using input/output files, and I got this long compile error that I don't understand.....
could anyone give me some insights??
Thanks so much!!
here are the errors and part of the code
errors:
prog4.cc: In function `int main()':
prog4.cc:51: no match for `_IO_ostream_withassign & >> string &'
/usr/local/gnu/lib/gcc-lib/sparc-sun-solaris2.6/2.95.2/../../../../include/g++-3
/std/bastring.cc:434: candidates are: class istream & operator >><char, string_c
har_traits<char>, __default_alloc_template<false,0> >(istream &, basic_string<ch
ar,string_char_traits<char>,__default_alloc_templa te<false,0> > &)
prog4.cc:57: parse error before `,'
prog4.cc:59: no match for `ostream & >> string &'
/usr/local/gnu/lib/gcc-lib/sparc-sun-solaris2.6/2.95.2/../../../../include/g++-3
/std/bastring.cc:434: candidates are: class istream & operator >><char, string_c
har_traits<char>, __default_alloc_template<false,0> >(istream &, basic_string<ch
ar,string_char_traits<char>,__default_alloc_templa te<false,0> > &)
prog4.cc: In function `float CalculatePremium(int, char, basic_string<char,strin
g_char_traits<char>,__default_alloc_template<false ,0> >)':
prog4.cc:86: ANSI C++ forbids comparison between pointer and integer
prog4.cc:182: ANSI C++ forbids comparison between pointer and integer
Code:#include <iostream> #include <string> #include <iomanip> #include <fstream> using namespace std; float CalculatePremium (int age, char gender, string type_coverage); //function prototype int main() { string first_name; //declare string variable first name string last_name; //declare string variable last name string gender; //declare string variable gender int age; //declare int variable age string type_coverage; //declare string variable type of coverage string club_member; //declare string variable health club member string smoker; //declare string variable smoker int zip_code; //declare int variable zip code int premium; //declare int variable premium ifstream inFile; //declare file streams ofstream outFile; inFile.open("inputdata"); //opens the file if(!inFile) { cout << "Input file failed!" << endl; return 1; //terminates the program if input fails } inFile >> first_name >> last_name >> gender >> age >> type_coverage >> club_member >> smoker >> zip_code; //assigns input values from inFile cout >> first_name >> last_name >> gender >> age >> type_coverage >> club_member >> smoker >> zip_code; //echos the input on the monitor while (inFile) //looping in capturing & processing input data { premium = CalculatePremium (int age, char gender, string type_coverage); outFile << first_name >> last_name >> type_coverage >> zip_code >> premium ; //output premium to file "output" inFile >> first_name >> last_name >> gender >> age >> type_coverage >> club_member >> smoker >> zip_code; //assigns input values to inFile outFile.open("output"); //creates output data } outFile.open("output"); if(!outFile) { cout << "Output file failed!" << endl; return 1; //terminates the program if output fials } }



LinkBack URL
About LinkBacks




)