|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CATCH3624 (59) | |||
Hello you guys...well I've been working on this project now for six days...I'm totally exhausted...can someone please look over this program and tell me how to correct the program in order for it to run......Thank You.......
| |||
|
Last edited on
|
|||
| Bazzy (6258) | |
|
Can you post the error messages? With a quick view I can see: Line 49: missing };Line 94: missing semicolon Line 101: Missing returnLine 124: should be int main
| |
|
|
|
| CATCH3624 (59) | |
|
I've corrected your comments and now I get just this one.... Compiling... Student.cpp .\Student.cpp(46) : fatal error C1075: end of file found before the left brace '{' at 'c:\documents and settings\darren\my documents\visual studio 2008\projects\person\person\Person.h(43)' was matched Build log was saved at "file://c:\Documents and Settings\Darren\My Documents\Visual Studio 2008\Projects\Person\Person\Debug\BuildLog.htm" Person - 1 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== | |
|
|
|
| CATCH3624 (59) | |
|
Disregard the last message...corrected...here are some of the error messages... .\Person.cpp(30) : error C2248: 'Person::lname' : cannot access private member declared in class 'Person' Person.cpp(31) : error C2248: 'Person::fname' : cannot access private member declared in class 'Person' Person.cpp(32) : error C2248: 'Person::dept' : cannot access private member declared in class 'Person' Person.cpp(33) : error C2248: 'Person::id' : cannot access private member declared in class 'Person' Person.cpp(34) : error C2065: 'H' : undeclared identifier .\Person.cpp(35) : error C2065: 'R' : undeclared identifier .\Person.cpp(39) : error C2556: 'std::string Employee::getH(void)' : overloaded function differs only by return type from 'float Employee::getH(void)' | |
|
|
|
| Bazzy (6258) | |||||
Declaration: float getH();Definition: -different return types- string Employee::getH() {return H;}Same for getR | |||||
|
|
|||||
| CATCH3624 (59) | |
|
ok...I've made those correction but I still get errors from H and R and some more..... float Employee::getH() {return H;}//Line 39 float Employee::getR() {return R;}//Line 40 void Employee::print() { Person::print(); cout<<" "<< }//Line 45 hour*rate;//Line 51 Student::Student(string L, string F, int i = 0, double g = 0.0) : Person(L, F, i), gpa(g) {} //Line 57 { lname = L; fname = F; dept = D; id = N; credit = C; } void Student::print() { Person::print(); cout << "GPA: " << gpa << endl; } //Line 72 Person.cpp(39) : error C2065: 'H' : undeclared identifier .\Person.cpp(40) : error C2065: 'R' : undeclared identifier .\Person.cpp(45) : error C2059: syntax error : '}' .\Person.cpp(51) : warning C4552: '*' : operator has no effect; expected operator with side-effect .\Person.cpp(57) : error C2511: 'Student::Student(std::string,std::string,int,double)' : overloaded member function not found in 'Student' .\Person.cpp(72) : fatal error C1004: unexpected end-of-file found | |
|
|
|
| CATCH3624 (59) | |
| Oh yeah...by the way...Thanks for all the help | |
|
|
|
| Bazzy (6258) | |||
Class Employee doesn't have members called H or R, you have hour and rate You still have some problems I pointed two posts ago: http://www.cplusplus.com/forum/general/16342/#msg81535 | |||
|
|
|||
| CATCH3624 (59) | |
|
Line 94: missing semicolon (won't work with or without it)... .\Person.cpp(44) : error C2059: syntax error : ';' Well all is corrected except for these three errors... Person.cpp(44) : error C2059: syntax error : ';' Person.cpp(58) : error C2511: 'Student::Student(std::string,std::string,int,double)' : overloaded member function not found in 'Student' Person.cpp(73) : fatal error C1004: unexpected end-of-file found | |
|
|
|
| Bazzy (6258) | |||
Try removing the default arguments value from the implementation | |||
|
|
|||
| CATCH3624 (59) | |
|
I've tried every thing possible...removing...renaming...adding...changing...all failed...all that's left are still these two errors... Person.cpp(58) : error C2511: 'Student::Student(std::string,std::string,int,double)' : overloaded member function not found in 'Student' Person.cpp(71) : fatal error C1004: unexpected end-of-file found Could there be a way possible for me to implement this class....???(would it be better than the one I'm using now...I also tried this one but ended up with more errors than the latter) class Student : public Person { private: double gpa; public: Student(string n, int i = 0, double g = 0.0) : Person(n, i), gpa(g) {} void display() { Person::display(); cout << "GPA: " << gpa << endl; } }; | |
|
|
|
| guestgulkan (2375) | |
|
Well you can't have done everything? The first error is saying that in person.cpp you have defined a member function of the Student class, that takes parameters, string, string, int, double. Have you declared such a function in the Student class - or is the one you declared in the student class string, int, double. ??????? For the second error: unexpected end-of-file found can be reported when you haven't matched up your { and } brackets properly - so a function isn't properly closed. | |
|
|
|
| herbert1910 (48) | |||||
|
your efforts come with full code and working examples! i like that. i will throw it in my compiler. make your "Student:public Person" match the other two classes in Person.h.
match your class definition with your class code. your constructor:
this constructor is never used, as far as i know. you could get rid of it here and in the class definition. i won't tell anyone. once you get past the syntax errors, like missing ; and }, you still have other mismatches. aStudent[i].setGPA(aDouble) has no Student::setGPA(double aDouble) or or a setGPA(double aDouble) in the Student class. same thing for SetFirstName and SetLastName. Student::getC, Student::setC. all those lonely functions. you may run into some odd output if you call Person::print() without giving a value to dept and id. your Person::print() cout line is missing stuff at the end. your Employee::cal_salary() is missing a return. Employee::getH doesn't have an H and Employee::getR doesn't have an R. other than that, it works fine. | |||||
|
|
|||||
| CATCH3624 (59) | |
| THANK YOU SO MUCH FOR ALL YOUR HELP...IT WAS NICE WORKING WITH YOU...YOU KEPT ME FOCUS AND DETERMINED NOT TO GIVE UP....I FOUND ANOTHER WORKING EXAMPLE BECAUSE OF YOU...IF YOU WOULD LIKE TO SEE WHAT I PUT TOGETHER JUST LEAVE ME A MESSAGE HERE...LOL | |
|
|
|
| herbert1910 (48) | |||||||||
YES! PM OR POST WHAT WORKED! I'M INTO THAT SORT OF THING!
oh! this is supposed to be a derived class constructor calling one of your base constructors to get Person::Person to initialize its data. that way, your call to Person::print wouldn't output strange nonsense for D and N. like:
similarly:
could be:
you would have to call your special Student and special Employee constructors with the right number of arguments. | |||||||||
|
|
|||||||||