+ 1
Objects and Classes
Hello Sololearners, Can anyone please give me a really simple explanation of classes and objects in C++, and how they would look like in code? (ie identity, what it looks like in code). Iâll give the person who answers the most simply but also the most informative a follow. Ty!
3 Answers
+ 3
Stonedev
A few things I put together, some copied from the courses & possible some from the net, I don't completely remember although I think they are properly credited . You might find them handy.
https://code.sololearn.com/csS9RE66ib4N/?ref=app
https://code.sololearn.com/cQ8PRV9dfmN2/?ref=app
+ 2
Let's say you create a class called cat which has one method called makesound().
Before you make an object this class it is useless, you cant do nothing with it because there no way of accessing it.
This when creating an object of this class becomes useful
Cat fluffy = new Cat();
Now you can use fluffy to access the object properties
Fluffy.makeSound();
let's say you create another
Cat fluffy2 = new Cat()
fluffy & fluffy2 are 2 separate entity's created from the same class.
+ 1
Classes are like the cookie cutters. They can create or instantiate objects. The objects are the actual cookies themselves.