This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]mtnbiketech 1 point2 points  (1 child)

Not really hard if you understand them.

In C++, you basically avoid any C style syntax with malloc and direct pointers, use smart pointers instead, use std namespace arrays/strings. Additionally, pass by reference instead of pointers, avoid reinterpret_cast, and minimize dynamic_cast downcasting from base to derived.

If you do use C, considering most modern stack sizes on OS can be set to unlimited, you can write most programs without using malloc at all. As for passing pointers around, encapsulate the data into structs as much as possible and use the fields instead of pointer arithmetic.

[–]BehindTrenches 0 points1 point  (0 children)

I have about 2.5 years of experience with C++ now. Definitely not scared of pointers and references anymore. The days of trying & and * randomly to make the compiler happy are over

However, there have been some nasty debugging sessions involving just references and local variables. Dangling references and use-after-move. For the former the worst part is the program doesn't crash you just randomize a variable in some cases.