3 ms·
I tried to learn "modern" C++ style, and watched many, many videos from cppcon, but I just don't feel like I understand how to do it. I started a C++ project, #
by holmak 10y ago
I tried to learn "modern" C++ style, and watched many, many videos from cppcon, but I just don't feel like I understand how to do it. I started a C++ project, #included <vector> and all the rest, and tried to do things the way the experts recommend, but I had no confidence that I was doing any of it right.
I know all the copying and moving and whatnot is supposed to "just work", but as far as I can tell, there's no easy way to verify that your program is doing what you intend. There also aren't any compact guidelines -- "follow these N simple rules and the STL won't explode!". With most other languages, I can at least think through the program to figure out if it is going to do what you intend, but the way that the STL is implemented to support all the modern C++ behavior requires a brain the size of a planet to understand.
I'm sure Stroustrup and the committee can write Modern C++, but I sure can't. Not with any confidence, anyway.
- lossolo 10y agoNo one said that C++ is easy, you need to teach yourself about pointers even if you will not use them so often, because almost everything under the hood is connected to pointers in some way. You need to learn the language. Watching video from ccpcon is not the way you will learn C++. Read book from Stroustrup about C++.
- holmak 10y agoI don't have any trouble with pointers. I can understand C programs just fine. But Modern C++, as the evangelists love to point out, is specifically about avoiding raw pointers in favor of smart pointers, value semantics, etc. That's the stuff that I find difficult to use. I did buy Stroustrup's post-C++11 book, "A Tour of C++", which is supposed to be the compact "how to do Modern C++". It provides tips, but as I mentioned above, I did not find it comprehensive enough. Terse recommendations like "Prefer returning by value" may be great small-scale recommendations, but they don't explain how the big picture is supposed to come together.
- lossolo 10y agoYou should watch those cppcon again, because Stroustrup and Herb are saying there many times that smart pointers are NOT should be use instead of raw pointers. Use smart pointers where It's about ownership. You should watch this video: https://www.youtube.com/watch?v=1OEu9C51K2A https://www.youtube.com/watch?v=1OEu9C51K2A