What makes member variables useful?

Question

What makes member variables useful?

Answer

Member variables are those that you want to be the same across all objects of a class. In our Car example, all cars should start off in new condition, so we set condition = "new" as a member variable.
However, things that might differ from car to car are their name and year_model! So for those things that are not the same across the board, we create instance variables.

5 Likes