回归C++开发:应选择C++11、C++14还是C++17?
Hey Steven, welcome back to the world of C++—it’s definitely been a wild ride since you last used it, right? Let’s break down your question to help you pick the right version to align with modern practices:
Why Start with C++14 First?
It’s a gentle extension of C++11: You’re already learning C11’s core modern features (lambdas, proper threads, etc.). C14 doesn’t throw any curveballs—it’s mostly polish and quality-of-life improvements on top of C++11:
- Lambda expressions can omit return types (the compiler auto-deduces them)
- Expanded
constexprsupport for more compile-time computations - Handy syntax like binary literals (
0b1010) and digit separators (1'000'000) - Standard library additions like
std::make_unique(a long-overdue complement to C++11’sstd::make_shared) andstd::integer_sequence
All these feel like natural extensions to what you’re already studying, so you won’t hit a steep learning curve.
Full support on Ubuntu 16.04: The default g++ 5.4 on Ubuntu 16.04 has complete, stable support for C++14. You just need to tweak your compile command to:
g++ -std=c++14 filename.cppNo need to mess with compiler upgrades or workarounds—you can focus on learning instead of troubleshooting your environment.
When to Move to C++17?
C17 brings some powerful new features (structured bindings, std::optional, std::variant, std::filesystem, etc.) that make modern C even more expressive. But there’s a catch on Ubuntu 16.04:
- The default g++ 5.4 only has partial, experimental support for C++17 (you’d use
-std=c++1zto enable it), and many key features are missing or buggy. - To use C17 properly, you’d need to upgrade your compiler to g 7 or later, which can introduce dependency headaches on an older LTS like 16.04.
My advice: Master C11 and C14 first—they already cover 90% of what you need for modern C++ practices (RAII, value semantics, avoiding raw pointers, leveraging the standard library, etc.). Once you’re comfortable with those, you can either:
- Upgrade your development environment to a newer Ubuntu LTS (20.04+ comes with g++ 9, which has full C++17 support)
- Use a container like Docker to spin up a modern environment without breaking your existing setup
Final Takeaway
Start with C14—it’s the sweet spot for your current setup and learning path. It builds on what you’re already studying, works seamlessly on your Ubuntu 16.04 machine, and gives you all the tools to write idiomatic modern C. Once you’re solid there, moving to C++17 will feel like a natural next step rather than an overwhelming leap.
内容的提问来源于stack exchange,提问作者Steven

