Tipps für C++ Speichermanagement?

Hey,

Ich programmier nun seit ca. 4-5 wochen in C++ (ich bin nach 6 Jahren C# Erfahrung umgestiegen) und mache grad auch ein etwas größeres Projekt. Ich hab leider nur das Problem das ich stääändig irgendwelche Probleme hab wenns um Speicher Allokation geht. Ich brauche meisten stunden um ein Problem zu fixxen was ziemlich demotivierend ist. Am besten nicht zu Basic sondern schon etwas tiefer in der Materie. Kennt jemand gute Quellen wo man sich darüber informieren kann.

(1 votes)
Loading...

Similar Posts

Subscribe
Notify of
1 Answer
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
JanaL161
6 months ago

(modern) C++ has constructs and models that should make you feel easier.

These include, for example, Const expressions, references, RAII, classes, destructors, modern types such as UTF strings, Smartpointer, Spans, Variants, concepts from functional programming such as Lambdas, Iterators, Optionals, etc.

(a) experience and (b) discipline. The first is in books and video courses (search terms: “modern / modern c++”, “professional c++”). After 4–5 weeks, however, you should still be at the basics and if at all, just slowly immerse yourself in such a thing. It is part of this to acquire the basics, make mistakes and learn from them.
To do without manual storage (alloc / new, free / delete), where there are vectors and secure strings for example, should bring a lot for the beginning. After that, you can look at destructors.

It is also appropriate to learn the safe use of debuggers (the tags say visual studio; there is already installed one that is very easy to use: https://learn.microsoft.com/de-de/visualstudio/debugger/debugger-feature-tour and optionally also ASSOCIATION to use: https://learn.microsoft.com/de-de/cpp/sanitizers/asan?

In the end, however, it is so that you will never get all this away; also the very best programmers build pile-wise bugs and memory management errors.

Here are some resources you asked for (only available online):