Instance vs Class Variables: Working With Classes

Published: 03 August 2020
on channel: Chris Strange
39
like

I use classes in my tutorials, but I have never done a video specifically about classes. That’s what this video is about.

I want to keep this video short so I thought I would pick one small topic to discuss: the difference between instance and class variables.
Class versus Instance Variables
Class variables are like global variables in the sense that they are available to all the instances of a class. This means that if a class variable is changed in one instance of the class that that variable is changed in ALL instances of the class. An instance variable, on the other hand, is only changed in the instance in which the change was made.

I’m going to demonstrate this by setting up a simple class called “Car.” CAR is a very simple class and only has tires and seats. The purpose of this class is to describe the cars I have and to keep track of their number.

Code on GitHub:
https://github.com/poly451/Tutorials/...


On this page of the site you can watch the video online Instance vs Class Variables: Working With Classes with a duration of hours minute second in good quality, which was uploaded by the user Chris Strange 03 August 2020, share the link with friends and acquaintances, this video has already been watched 39 times on youtube and it was liked by like viewers. Enjoy your viewing!