0
Is the way iv gotten this code right? Honestly am i supposed to take the program class individually?
Question goes like- Getting multiple functions/methods for a program 1. Get a function to get 2 user input 2. Get a function to add it 3. Get a function to print it My question is.. when I use parameters/or without parameters by not making a new program function it gives an error... https://sololearn.com/compiler-playground/c09LIS3k4BYU/?ref=app https://sololearn.com/compiler-playground/cEDNXgkmrhp2/?ref=app
2 Antworten
+ 1
I didn't fully understand what you need, but in order for the function to support calls without parameters, it needs to be overridden.
I made some adjustments to your code:
https://sololearn.com/compiler-playground/cFlaE1y8VJA6
And you got the error because the method does not accept the required values, in other words, it is not overridden.
+ 2
It might be just a course problem, but it is teaching unnecessary complications. There are practical uses for such an approach, but that is just a bad use case.
Using functions for every operation is just adding complication. Unless it's a complicated operation that's going to be reused a lot of time, it's better to spend the effort properly handling the input parsing and handling edge cases than compartmentalizing every operation into functions.
https://sololearn.com/compiler-playground/cgy155oTPLyz/?ref=app