![]() |
| ||
| Help Needed on C++ assignment Hi, Wondering if I could get some help. This program is supposed to : -Input student data(firstname,lastname,student#, and a vector of Grades(up to 10 grades) with a grade and assignment name(notworking)) from a text file and store it in a vector -Have a menu system for navigation -add a student ---Working -delete a student --- not working -modify a student --- not working, dont know how to access student and modify the non-working struct vector of Grades, i need help with this -quit (save vector in text file on quit--this is not working, im not using ofstream right) Vectors/iterators must be used Here is my bug ridden code, I know it's crappy, but any help, suggestions, comments, would be greatly appreciated. Thanks, Dev
|
| ||
| Re: Help Needed on C++ assignment >Here is my bug ridden code Bug-ridden? It won't even compile! There's way too many for me to fix now, how about posting the error messages you receive so other people can help you find what is making them occur? |
| ||
| Re: Help Needed on C++ assignment OKay , here is the udpated code, a bit more sorted out, just a few problems generating 21 errors. First of all I'm not using the right fstream commands or something for output to a text file. Please help. (line 389-402) Second, when doing a comparison of strings, like "if ( ((*it).getStudentNumber) == ssn)" doesnt work, how do i do this properly? (line 268 etc) Lastly, how do i properly delete a student from the vector of students? "delete (*it);" not working. (line 377) Also, am i declaring the struct properly in the student.h? Also, what am i forgetting with my printGrade function for student, it doesnt work, here is my list of errors the compiler throws at me. 1>c:\documents and settings\dev\my documents\c++\p4\main\main\main.cpp(147) : error C2784: 'bool std::operator ==(const std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem *)' : could not deduce template argument for 'const std::basic_string<_Elem,_Traits,_Alloc> &' from 'overloaded-function' 1> c:\program files\microsoft visual studio 8\vc\include\string(91) : see declaration of 'std::operator ==' 1>c:\documents and settings\dev\my documents\c++\p4\main\main\main.cpp(147) : error C2784: 'bool std::operator ==(const _Elem *,const std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'const _Elem *' from 'overloaded-function' 1> c:\program files\microsoft visual studio 8\vc\include\string(81) : see declaration of 'std::operator ==' 1>c:\documents and settings\dev\my documents\c++\p4\main\main\main.cpp(147) : error C2784: 'bool std::operator ==(const std::basic_string<_Elem,_Traits,_Alloc> &,const std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'const std::basic_string<_Elem,_Traits,_Alloc> &' from 'overloaded-function' 1> c:\program files\microsoft visual studio 8\vc\include\string(71) : see declaration of 'std::operator ==' 1>c:\documents and settings\dev\my documents\c++\p4\main\main\main.cpp(147) : error C2784: 'bool std::operator ==(const std::vector<_Ty,_Alloc> &,const std::vector<_Ty,_Alloc> &)' : could not deduce template argument for 'const std::vector<_Ty,_Alloc> &' from 'overloaded-function' 1> c:\program files\microsoft visual studio 8\vc\include\vector(1259) : see declaration of 'std::operator ==' 1>c:\documents and settings\dev\my documents\c++\p4\main\main\main.cpp(147) : error C2784: 'bool std::operator ==(const std::istream_iterator<_Ty,_Elem,_Traits,_Diff> &,const std::istream_iterator<_Ty,_Elem,_Traits,_Diff> &)' : could not deduce template argument for 'const std::istream_iterator<_Ty,_Elem,_Traits,_Diff> &' from 'overloaded-function' 1> c:\program files\microsoft visual studio 8\vc\include\iterator(266) : see declaration of 'std::operator ==' 1>c:\documents and settings\dev\my documents\c++\p4\main\main\main.cpp(147) : error C2784: 'bool std::operator ==(const std::allocator<_Ty> &,const std::allocator<_Other> &) throw()' : could not deduce template argument for 'const std::allocator<_Ty> &' from 'overloaded-function' 1> c:\program files\microsoft visual studio 8\vc\include\xmemory(174) : see declaration of 'std::operator ==' 1>c:\documents and settings\dev\my documents\c++\p4\main\main\main.cpp(147) : error C2784: 'bool std::operator ==(const std::istreambuf_iterator<_Elem,_Traits> &,const std::istreambuf_iterator<_Elem,_Traits> &)' : could not deduce template argument for 'const std::istreambuf_iterator<_Elem,_Traits> &' from 'overloaded-function' 1> c:\program files\microsoft visual studio 8\vc\include\xutility(2143) : see declaration of 'std::operator ==' 1>c:\documents and settings\dev\my documents\c++\p4\main\main\main.cpp(147) : error C2784: 'bool std::operator ==(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'overloaded-function' 1> c:\program files\microsoft visual studio 8\vc\include\xutility(1826) : see declaration of 'std::operator ==' 1>c:\documents and settings\dev\my documents\c++\p4\main\main\main.cpp(147) : error C2784: 'bool std::operator ==(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'overloaded-function' 1> c:\program files\microsoft visual studio 8\vc\include\utility(60) : see declaration of 'std::operator ==' 1>c:\documents and settings\dev\my documents\c++\p4\main\main\main.cpp(147) : error C2677: binary '==' : no global operator found which takes type 'std::string' (or there is no acceptable conversion) 1>c:\documents and settings\dev\my documents\c++\p4\main\main\main.cpp(245) : error C2784: 'bool std::operator ==(const std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem *)' : could not deduce template argument for 'const std::basic_string<_Elem,_Traits,_Alloc> &' from 'overloaded-function' 1> c:\program files\microsoft visual studio 8\vc\include\string(91) : see declaration of 'std::operator ==' 1>c:\documents and settings\dev\my documents\c++\p4\main\main\main.cpp(245) : error C2784: 'bool std::operator ==(const _Elem *,const std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'const _Elem *' from 'overloaded-function' 1> c:\program files\microsoft visual studio 8\vc\include\string(81) : see declaration of 'std::operator ==' 1>c:\documents and settings\dev\my documents\c++\p4\main\main\main.cpp(245) : error C2784: 'bool std::operator ==(const std::basic_string<_Elem,_Traits,_Alloc> &,const std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'const std::basic_string<_Elem,_Traits,_Alloc> &' from 'overloaded-function' 1> c:\program files\microsoft visual studio 8\vc\include\string(71) : see declaration of 'std::operator ==' 1>c:\documents and settings\dev\my documents\c++\p4\main\main\main.cpp(245) : error C2784: 'bool std::operator ==(const std::vector<_Ty,_Alloc> &,const std::vector<_Ty,_Alloc> &)' : could not deduce template argument for 'const std::vector<_Ty,_Alloc> &' from 'overloaded-function' 1> c:\program files\microsoft visual studio 8\vc\include\vector(1259) : see declaration of 'std::operator ==' 1>c:\documents and settings\dev\my documents\c++\p4\main\main\main.cpp(245) : error C2784: 'bool std::operator ==(const std::istream_iterator<_Ty,_Elem,_Traits,_Diff> &,const std::istream_iterator<_Ty,_Elem,_Traits,_Diff> &)' : could not deduce template argument for 'const std::istream_iterator<_Ty,_Elem,_Traits,_Diff> &' from 'overloaded-function' 1> c:\program files\microsoft visual studio 8\vc\include\iterator(266) : see declaration of 'std::operator ==' 1>c:\documents and settings\dev\my documents\c++\p4\main\main\main.cpp(245) : error C2784: 'bool std::operator ==(const std::allocator<_Ty> &,const std::allocator<_Other> &) throw()' : could not deduce template argument for 'const std::allocator<_Ty> &' from 'overloaded-function' 1> c:\program files\microsoft visual studio 8\vc\include\xmemory(174) : see declaration of 'std::operator ==' 1>c:\documents and settings\dev\my documents\c++\p4\main\main\main.cpp(245) : error C2784: 'bool std::operator ==(const std::istreambuf_iterator<_Elem,_Traits> &,const std::istreambuf_iterator<_Elem,_Traits> &)' : could not deduce template argument for 'const std::istreambuf_iterator<_Elem,_Traits> &' from 'overloaded-function' 1> c:\program files\microsoft visual studio 8\vc\include\xutility(2143) : see declaration of 'std::operator ==' 1>c:\documents and settings\dev\my documents\c++\p4\main\main\main.cpp(245) : error C2784: 'bool std::operator ==(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'overloaded-function' 1> c:\program files\microsoft visual studio 8\vc\include\xutility(1826) : see declaration of 'std::operator ==' 1>c:\documents and settings\dev\my documents\c++\p4\main\main\main.cpp(245) : error C2784: 'bool std::operator ==(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'overloaded-function' 1> c:\program files\microsoft visual studio 8\vc\include\utility(60) : see declaration of 'std::operator ==' 1>c:\documents and settings\dev\my documents\c++\p4\main\main\main.cpp(245) : error C2677: binary '==' : no global operator found which takes type 'std::string' (or there is no acceptable conversion) 1>c:\documents and settings\dev\my documents\c++\p4\main\main\main.cpp(256) : error C2440: 'delete' : cannot convert from 'Student' to 'void *' 1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called 1>Student.cpp 1>Generating Code... 1>c:\documents and settings\dev\my documents\c++\p4\main\main\student.cpp(61) : warning C4715: 'Student::printGrades' : not all control paths return a value
|
| ||
| Re: Help Needed on C++ assignment Good job, you've definitely fixed a number of syntax errors already. Basically 2 things I saw: if ((*it).getStudentNumber) == ssn)Since getStudentNumber is a function, you'll have to put () after the function name. Otherwise you're comparing function pointers, which is something entirely different.Using delete to deallocate a vector? If you need to empty it, you can always use vector::clear, but the destructor of std::vector automatically takes care of this, so no worries here. |
| ||
| Re: Help Needed on C++ assignment But if you still want to use delete (which would be a good thing), consider dynamically allocating the vector using the new operator. |
| ||
| Re: Help Needed on C++ assignment Okay, Got everything error free , thanks alot, however there is some runtime difficulties. First, and hopefully only, when I load up the student and the grades, it doesnt work :p it worked initially, but now when it displays the student when it first loads and displays the students, its not workin. So any help, much appreciated.... //******************* //studentData.txt example //******************* Devin Grove 222-234-567 history111 85 calculus222 99 Kath Puza 345-678-665 history111 85 calculus222 99 Tom Geonger 325-235-256 history111 85 calculus222 99 history111 85 Dude Willis 123-157-643 history111 85 calculus222 99 Oscar Myer 305-246-789 history111 85 calculus222 99 Julia Wicchaa 242-657-543 history111 85 calculus222 99 calculus222 99
|
| ||
| Re: Help Needed on C++ assignment double post |
| ||
| Re: Help Needed on C++ assignment //THIS DOESNT WORK, how do i compare the strings properly? if ( (*it).getStudentNumber() == ssn) Erm, don't you think you have your logic mixed up? |
| All times are GMT -4. The time now is 10:26 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC