M
M
MDtox2018-02-08 23:42:55
C++ / C#
MDtox, 2018-02-08 23:42:55

Is it mandatory to use pointers in C++ for games?

Will there be a memory leak or some problem if I don't use them?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey, 2018-02-09
@MDtox

Is it mandatory to use pointers in C++ for games?
- I do not want to offend, but it follows from the question that you do not understand the pointer mechanism, the structure of programs in memory, optimizations and, as a result, you are very poorly oriented in C++.
At this stage, writing in C++ is not worth it if there is no need (university, work).
You have two options:
1) look towards c#. You can write games on it, in the process you will get used to it a little better and be ready for all the "goodies" of C ++. Moreover, you are a beginner and the pluses of c ++ will come in handy for you, oh, how not soon, and the excessive complexity of the pluses can discourage the desire to code, especially for beginners
2) give up the idea of ​​​​writing a game))))

S
Stanislav Makarov, 2018-02-09
@Nipheris

Is it necessary to use C++ for games?

P
Pavel Mikhalovsky, 2018-02-09
@pavel9609

If you do not use dynamic memory, then it is quite possible. And this is quite difficult, you will have to set hard limits for most elements. Of course, now there are STL, vectors and lists out of the box, but you also need to follow them. And so you can not do without pointers. + Some libraries can simply force you to use pointers.
Pointers and dynamic data structures are easy to follow. You need to understand when you allocate memory to them and you need to understand when the occupied memory needs to be cleared. In other modern languages, the garbage collector does this for you; C and C++ don't.
However, if you are so afraid of pointers, then you better switch to another language, since all the charm in C ++ is in memory management, and without it you are better off using another language.
PS Read about smart pointers.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question