Are arguments necessary for class functions or not? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Are arguments necessary for class functions or not?

I have seen examples which have arguments end some which do not even though the variables are in the class in both the cases

10th Jun 2017, 6:48 AM
potato
potato - avatar
2 Answers
+ 1
Arguments for class functions certainly aren't necessary for some examples. It all depends on what you want the function to do. Maybe you could post the examples you're asking or clarify why you want to know if it's necessary or not.
10th Jun 2017, 6:59 AM
Zeke Williams
Zeke Williams - avatar
+ 1
Well technically, all class methods always have one parameter under the hood. A pointer to the class instance is passed into each method as the first parameter. (Your compiler does this for you) But past that there doesnt need to be any other parameters, so it's up to you of course.
10th Jun 2017, 7:50 AM
aklex
aklex - avatar