+ 1
What is the advanrtages of class??
2 Réponses
+ 1
C++ is an object-oriented programming language which means that C++ gives you the tools to make programming more like coping with the real world.
The real world has objects, like humans, cars, motorcycles. Objects have certain characteristics, for example names or age for humans. Humans can also do something, for example tell you their name or throw a ball. Every human has characteristics and things they can do. So you could say you could put all humans into a class.
These classes contain everything that makes humans human. Their characteristics as variables and things theiy can do as member functions.
For example:
class human{
private:
string name; //characteristic
public:
void sayhello(); //Thing human can do: say hello
};
A class is a perfect blueprint for the creation of new object of the class's type. It is an enhancement of the structs you know from the C programming language since they include member functions.
They help the coder to put real-world objects into code more easily :)
- 2
Separating workers from capitalists



