D
D
DenY22015-01-15 23:57:26
Programming
DenY2, 2015-01-15 23:57:26

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

6 answer(s)
Z
zed, 2015-01-16
@zedxxx

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.

T
tsarevfs, 2015-01-16
@tsarevfs

Why are you not satisfied with the first link from the query in Google: c++ classes examples ?

R
ReD, 2015-01-16
@trinitr0

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).

D
Dum_spiro_spero, 2015-01-16
@Dum_spiro_spero

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.

A
AxisPod, 2015-01-28
@AxisPod

Great question. And tell me, how is your body actually different from the place you think?

V
Vitaly, 2015-01-16
@vt4a2h

Open any C++ book and read thoughtfully from the first to the last page, typing all the code and doing the tasks along the way.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question