Quick Answer please

Started by
5 comments, last by Mizipzor 15 years, 7 months ago
Hey. I am just finishing off a project for a course and have come across one problem. So you dont really need to tell me the answer but if you could helf me understand it that would be cool. Basically its making a pump. and we have a class which they have already written and iv just implimmented that in fine. However iv got to a point where it reads - bool Deliver(float increment). And thats what i need to put in to get it to return me something. But i have tryed putting it in as Pump.Deliver(); ( // pump being my class type) And i get this error message when trying to run - Too few parameters in call to "PumpType::Deliver(float)" Could i stress that i cant really be told the answer as it's for a course but help with a reason why and what i would need to do :)
Advertisement
Your function expects a parameter and you are not providing one when you call it. Google for the error code and you'll get more examples.
Is a perameter like -

#include <iostream.h>
Quote:Original post by Twinsen LBA
Is a perameter like -

#include <iostream.h>
No. Dave was referring to a function parameter (the above is a preprocessor directive - and incidentally, it should be <iostream>, not <iostream.h>).
Quote:Original post by Twinsen LBA
bool Deliver(float increment)
Pump.Deliver();

You are missing the argument. It's like asking "What is the square root?" instead of "What is the square root of 49?".
As you said yourself, your function is declared as bool Deliver(float increment). This means it takes a parameter of type float (a fraction basically) and returns a bool (true or false). When you declare a function, you list its parameters' types and names in between parentheses. Similarly, when you call a function, you put the parameter itself in parentheses - as in Pump.Deliver(0.5); // 0.5 is a parameter

Now, since i have no idea what your function does with that parameter, i can't advice on which exact value it should be. But it basically expects you to put some number in there, which would stand for your pump's delivery increment (whatever that means).
On a sidenote, functions can have default parameter values to make your code compile. But reading your post, I dont think thats where you went wrong. Go with what ertyqwer said, otherwise google the compile error code.

This topic is closed to new replies.

Advertisement