Programming week 3 – Classes
|
This week we have been going through Classes and Class Inheritance. which felt like an easier concept to grasp than the previous, since we had already been working with this a bit when creating ”Pong” earlier in the course. Classes are just like variables different data structures that can be called within the main function, they can have different functions inside of them. That way we can use classes to reduce the amount of code we have to write, making it a lot less painful to actually code millions of lines of codes day out and day in. What Class inheritance means is that you can create a class, then create another class and let it inheritance all of the public variables or methods in the original class. It’s messy, I know.. But for instance if you create a class named ClassExample, and give it the variables int x = 0 and int z = 0, you can easily give another class those variables as well. By typing for instance ”Class InheritancedClass : public ClassExample” you will pass on all those variables to the newly created class, saying you inherited them. |