0

How to add a variable into a class which is not defined in the class. I want to add it after creating the class.

class Car { string color = "red"; } After creating the class I want to add some more variables. For example : int weight =256; int speed= 234; I want to add these variables in the car class. How can I do it?

21st Mar 2021, 7:01 AM
Mahdiuzzaman Nishat
Mahdiuzzaman Nishat - avatar
2 Respuestas
0
Can I add those variables while creating a object?
21st Mar 2021, 7:38 AM
Mahdiuzzaman Nishat
Mahdiuzzaman Nishat - avatar
0
But what's a problem to declare them directly inside the class?
21st Mar 2021, 8:16 AM
Nazeekk
Nazeekk - avatar