class and object definition | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

class and object definition

https://www.sololearn.com/compiler-playground/c5fpjj03M34O in this code question i wanted to keep it by just horsepower( withoout this horsepowers = x declaration) but when i do that it just returns 0. why i have to declare horsepowers as x ?? Why i can't just use only horsepowers

18th Dec 2022, 4:39 PM
Lalala
Lalala - avatar
2 Respuestas
+ 2
What did you mean without `horsepowers = x;` That line copies value of argument <x> into private member <horsepowers>. No way to set car engine's horse power attribute without it Tell me if I misunderstood you ...
19th Dec 2022, 3:15 AM
Ipang
0
Lalala The link isn't working. Pls try like this: tap "+" button, then "Code", and select your code.
20th Dec 2022, 12:34 AM
Emerson Prado
Emerson Prado - avatar