Join 136,149 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,065 people online right now. Registration is fast and FREE... Join Now!
Hi my compile is displaying the errors below. I do not know why. Does anyone think it's my compiler b/c it gives me tons of problems. Can anyone give any suggestions or hints? Thanks. error C2064: term does not evaluate to a function taking 1 arguments for this part
Well I am shooting from the hip here... but I count at least 3 different uses for the identifier "tot_avg" -- You declare it a float variable in the process() function. It is a function, AND another float value in the function of the same name tot_avg(). You know there ARE other variable/function name out there.
Try changing the name of the function tot_avg to something flashy like "Calculate_Total_Average" and I bet it would solve that problem. -- Since the identifier tot_avg inside process() is within the scope of that function and therefore a float variable -- not a function taking 1 argument.
No2Pencil has the other.
Note... if you get errors chances are its you, not the compiler. Granted I don't think in the first case your compiler gave you very much information. I would have expected such an error to be even more cryptic saying something about conversion of data type float to float (*)(float). So another compiler might give you more or less descriptive error information... Heck it might even find errors in a totally different order. But always take a careful look at your code.
Believe me I have cursed compiler writers and their mothers... but in the end it has always been my fault. -- so far.
1. Take the semicolon out of your initial if satement 2. You can take that else out completely since you are only checking one thing. Which should solve your illegal matching situation.
and with your function problems.. like the other guy suggested, rename your variables/functions to something more meaningful and give it a go.. try not to give variables and functions the exact same name
Suggestion: An even better thing to do is when you try to open the file initially make a while statement that says "while the file name is bad prompt the user for the info again". This will save you from even doing an else/if statement since if you get out of that while statement you know you have a valid file.
This post has been edited by Topher84: 4 Jun, 2007 - 09:49 AM
thanks a bunch. it's amazing how i can sit here for hours and not even notice these mistakes. its so frustrating, you're all geniuses, i dont know how you do it hopefully one day i will !! thanks again.
thanks a bunch. it's amazing how i can sit here for hours and not even notice these mistakes. its so frustrating, you're all geniuses, i dont know how you do it hopefully one day i will !! thanks again.
np you gotta start somewhere if you are programming in visual studios you should get to be really good buddies w/ the debugger which normally will solve 99% of little problems
thanks a bunch. it's amazing how i can sit here for hours and not even notice these mistakes. its so frustrating, you're all geniuses, i dont know how you do it hopefully one day i will !! thanks again.
np you gotta start somewhere if you are programming in visual studios you should get to be really good buddies w/ the debugger which normally will solve 99% of little problems
It is often easier to troubleshoot someone else code rather than your own. The reason it that you mind understands the logic behind what you did -- you know what you mean, but the compiler doesn't. The same kind of thing often happens in written language. I have read back over papers I turned in at school and found myself wondering how I ever passed a class.
When you are really stuck on a problem there are a few things you can do. #1 Try the debugger -- often this will help you see what it happening. #2 Print it out. -- I don't know why, but at least for me, I think better on paper. You can make notes, you can doodle, you can draw flow charts, all little things that help you see your code from different angles. #3 Sleep on it. Take a walk, get a sandwich, take your wife (or husband, women program too) to dinner and beyond, get your mind away from the problem. -- Just the other day there was a post here that I just could not solve, I even went so far as to tell the poster that they would have to seek higher wisdom. I went to bed, and woke up with the answer. #4 Rewrite the offending code from scratch. I don't know why, but sometimes my brain just needs a reboot. Often in the trouble shooting process I have learned more about what I am trying to accomplish and the rewrite works better anyway. (again the same can often be said for written language).
When you are really stuck on a problem there are a few things you can do. #1 Try the debugger -- often this will help you see what it happening. #2 Print it out. -- I don't know why, but at least for me, I think better on paper. You can make notes, you can doodle, you can draw flow charts, all little things that help you see your code from different angles. #3 Sleep on it. Take a walk, get a sandwich, take your wife (or husband, women program too) to dinner and beyond, get your mind away from the problem. -- Just the other day there was a post here that I just could not solve, I even went so far as to tell the poster that they would have to seek higher wisdom. I went to bed, and woke up with the answer. #4 Rewrite the offending code from scratch. I don't know why, but sometimes my brain just needs a reboot. Often in the trouble shooting process I have learned more about what I am trying to accomplish and the rewrite works better anyway. (again the same can often be said for written language).
These are all great tips. The only one I would add is, explain it to someone that doesn't know anything about programming. Spelling it all out in plain English causes you to go through the process in great detail. I usually find a simple error by 'beach-combing' in this manor. In fact, I often times find myself stopping mid sentence & running off to the computer.
explain it to someone that doesn't know anything about programming.
Here here! This is a good step. Though it does not have to be someone who knows nothing of programming... just spell it out in plain language (doesn't have to be english )
1. Don't try to do it all in one giant step.. take baby steps.. as in work on one function at a time until it is correct before you move on! i can't count how many times i've tried to write a complete program in one go only to have created way more problems than I needed!
great tips, its hard to get help b/c no one has a clue what im talking about in the real world. the tips all make so much sense. i like the ones about printing it and doing one function at a time. o and yessssss women do program too though at times i feel like im the only one. LOL