Why we use class? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why we use class?

i dont know when use i class ? لا أعلم متی أستعمل الکلاس

8th Jan 2017, 11:17 AM
abdellah khaddou
abdellah khaddou - avatar
1 Answer
+ 1
Classes are used to define programmatic objects. It is not merely about making code more readable, but also more extensible. For instance, if you define a class "person", that class can contain all the required variables to describe a person, such as name, age, height, weight. You can then inherit the "person" class in an "employee" class that adds information such as department, id_number. But you can also inherit the "person" class into a "customer" class that has info you need to track your customer and get in touch, such as email_address. The class can also include methods that your program can use to interact with the objects. It'll all come up later in the course.
8th Jan 2017, 1:25 PM
Myk Dowling
Myk Dowling - avatar