Shouldn't a parameter be a variable? How can an object be a parameter? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Shouldn't a parameter be a variable? How can an object be a parameter?

4th Jan 2017, 9:48 AM
박경록
박경록 - avatar
3 Answers
+ 6
You assign the object into a variable... ~_~ (also, who said that it cannot be an object?)
4th Jan 2017, 9:50 AM
Valen.H. ~
Valen.H. ~ - avatar
+ 3
the thing is that every variable is an object, an instance of a class. So then an object can be a parameter. For example an int variable is an object, an instance from the class Int. So your actually always using instance of classes.
3rd Mar 2017, 7:19 PM
Dennis Bode
Dennis Bode - avatar
+ 2
The data types such as an int, a double and the others are also objects.That's why each of them has their unique members and member functions that we usually use.So when passing a primitive data type, you might as well think of it as an object. Thus, it is possible to pass an object as a parameter.
10th Apr 2017, 8:15 AM
Lehlohonolo
Lehlohonolo - avatar