![]() |
| ||
| Homework Function Compile Errors I am having a problem with a program. I have to create a program with about 8 different functions. Which reads in votes, finds the max, the min, prints the votes, prints the max prints the mid, finds the normalization, outputs how many are below .25 and above .75 and prints the normalization. I've got the program typed but I'm coming up with alot of errors when I compile. Can anyone help me out with these problems? Thanks, SportsFilmer #include <iostream> Here are the errors I'm getting: p7a.cpp:18: warning: unused variable 'min' p7a.cpp:18: warning: unused variable 'max' p7a.cpp: In function 'void print2(double*, int, int)': p7a.cpp:81: error: no match for 'operator<<' in 'std::operator<< [with _Traits = std::char_traits<char>](((std::basic_ostream<char, std::char_traits<char> >&)(& std::cout)), ((const char*)"The location is")) << std::max' /usr/local/lib/gcc/sparc64-sun-solaris2.10/4.1.1/../../../../include/c++/4.1.1/bits/ostream.tcc:67: note: candidates are: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>& (*)(std::basic_ostream<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>] /usr/local/lib/gcc/sparc64-sun-solaris2.10/4.1.1/../../../../include/c++/4.1.1/bits/ostream.tcc:78: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ios<_CharT, _Traits>& (*)(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>] /usr/local/lib/gcc/sparc64-sun-solaris2.10/4.1.1/../../../../include/c++/4.1.1/bits/ostream.tcc:90: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>] p7a.cpp:90: error: invalid operands of types '<unresolved overloaded function type>' and '<unresolved overloaded function type>' to binary 'operator-' p7a.cpp:92: error: 'i' was not declared in this scope p7a.cpp:94: error: 'vote' was not declared in this scope p7a.cpp:94: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator/' p7a.cpp: At global scope: p7a.cpp:98: error: 'top' has not been declared p7a.cpp: In function 'void normquart(double*, int, int)': p7a.cpp:100: error: declaration of 'int bottom' shadows a parameter p7a.cpp:101: error: 'i' was not declared in this scope p7a.cpp:103: error: 'vote' was not declared in this scope p7a.cpp:103: error: expected primary-expression before '<' token p7a.cpp:106: error: expected `(' before 'else' p7a.cpp: At global scope: p7a.cpp:114: error: expected initializer before numeric constant |
| ||
| Re: Homework Function Compile Errors Most of the errors you get are typing errors I presume. For instance, a lot of times you use max or min, where you're giving min or maxloc as argument to the function. Also some variables are just not declared in a function, remember that each function has it's own variables if they are not declared globally or given as arguments. EDIT: a second look at your code tells me that some errors you are having are also forgetting { or not knowing the syntaxis. Also, in your main function you have this: int main() {The problem with this code is that maxloc and minloc are not initialised, which means they can be any value. You have to give them a startvalue, (I don't know how your program works, just corrected some errors quickly) Hopefully this can help you further... |
| ||
| Re: Homework Function Compile Errors RTFM - Read The Full Message They tell you where the problem is and what it is. Even if you don't fully understand the messages, they're pointing you to the problems. Look closely. |
| All times are GMT -4. The time now is 3:51 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC