Answer the question
In order to leave comments, you need to log in
How are Classes different from normal functions? C++?
I've been asking this question for a long time, so I can't understand the meaning of classes. What are they needed for. I can not find an example that demonstrates the use of classes in all its glory ((
Answer the question
In order to leave comments, you need to log in
There is such a programming paradigm - OOP , which is built on classes and objects. And there is procedural programming , where procedures are the main brick.
If you do not understand what classes are for, then you are not familiar with OOP. Learn what kind of animal it is and everything will fall into place.
Why are you not satisfied with the first link from the query in Google: c++ classes examples ?
Not "rather", but the class is the data type, in fact.
Why is this needed? That's why - continuing the example with the class of complex numbers, then in this class you can introduce your own methods (read functions). But then we will be able to work with complex numbers as a separate type with its own functions (or overload the existing ones and work with the usual functions).
It's simple - a class is not a function - a class is more of a data type including how to work with it. Type of structure - but to which their functions are also added.
A boring example - for example, you need complex numbers - and methods of multiplication, division, etc. for them ... which is not in the standard implementation. (Although it may already be).
The complexity of understanding is usually why it is needed - you can do everything with functions.
Yes, you can - but with classes it is more convenient if you think through everything first.
Great question. And tell me, how is your body actually different from the place you think?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question