225k views
12 votes
What potential problems could come up if I tried to use a function without knowing what it does or how to interact with it?

2 Answers

10 votes

Answer:

My friend wants to use my findSmallest() function in her program. Is this function ready to be shared in a library? Why or why not? This is the answer to the next question.

Step-by-step explanation:

No, this code is not ready to be shared in a library. This is because this code has a global variable that will only allow the code to work for one case and cannot be applied to other problems my friend might have. This function also does not have a return call which will result in no answer when fed with an input.

User Volodymyr Machula
by
6.0k points
2 votes

Answer:

You won't get the result you are expecting. Or you may get a result, you just don't know what it represents. Or the function could do any number of other things that may effect values already stored in the instance of the class that you weren't intending. It all depends on what the function is and how dependent other things are on it.

User Ndonohoe
by
6.4k points