I'm very new to C++ and I am having trouble understanding what Object Orientated means and what classes are and what they do.
I would be really grateful if someone could help me to understand these things.
I'm very new to C++ and I am having trouble understanding what Object Orientated means and what classes are and what they do.
I would be really grateful if someone could help me to understand these things.
Here's my 2 cents worth:
In real life objects have certain attributes: color, names, parts, size, weight, etc. and can do certain things: speak, run, turn, display, etc. Classes and structs allow you to incorporate those attributes and activities associated with a given object in your code. Each instance of a class or a struct is called an object and, hence, the term OOP. In real life as well as in OOP, different objects can be related to one another through inheritance (for example a dog class may inherit all the attributes of an animal class) or inclusion (for example both car and engine are objects but the car has an engine (usually)).
Object oriented coding also helps you be more precise in coding which frequently helps you find bugs in code at compile time when it is easier to fix and it allows you to protect data from unexpected changes among other helpful features.
These features of OOP can be very useful or may be absolutely worthless to you in a given program; so you use them when needed and forget about them when you don't.
So each 'object' has certain attributes, and a class lets me use those attributes with something else?
A class just says what attributes an object has, and what actions it can perform. An object, on the other hand, is an instance of a class, with the attributes set to actual values, and actually able to perform those specified actions.
a simple understanding is a ball... the class would say a ball is round, it has a color, a weight... the object would be that fould ball you caught at the red sox game, another object is the kick ball your kid is playing with outside.
Ah thank you. Now I should be able to understand these tutorials a bit better.