Need Help With My Function

I'm very new to C++, and this is my first time trying to use functions. For my CS class we have to write a program that reads data in from an input file, does calculations based on which line of data the program is on, and output the data. I decided to try to use functions to do the calculations. My issue is I don't know what to put in my parameters in order to call my function.

My function checks which rock is being read from the input file and does calculations based on which rock it is. Here is the function I wrote:

https://ibb.co/zNzMWzQ

So based off of which rockTypeShape is read, it performs that calculation.

Yet when I try to call it as I do here //LINE 143!!!!!

https://ibb.co/1Zybdc4

I am met with the error "too many arguments in function call".
Can somebody help me with my parameters or what to put in them?
I have tried putting (string rockTypeShape) as the parameters but that did not work. I have reached out to TA's but havent gotten a response yet.
I am down to message back and forth via email or discord or something.
Thanks a bunch in advance!
-V
Hello vexxt,

First it would help if you post the whole program and not just the parts that you think are a problem.

Functions tend to have three parts. The prototype, function call and function definition. The prototype and function definition must match with respect to their return value , if any, and the parameters. The function call only needs to the name of the variable to the function.

If I understand your code correctly double surfaceCalc() should be
double surfaceCalc(std::string rockTypeShape, double edgeLength). This defines "rockTypeShape" and "edgeLength" as a local variables to the function and allows a string to be sent to the function along with the "edgelngth". I tend to copy the function definition and use it for the prototype, but the minimum for the prototype would be "std::string, double" the variable name is not a requirement.

With out the rest of the code it is only a guessing game to figure out what you have done.

Hope that helps,

Andy
Thanks Andy!
I sent you a PM. :)
Topic archived. No new replies allowed.