What is C++11?
On August 12, 2011, the ISO (International Organization for Standardization) approved a new version of C++, called C++11. C++11 adds a whole new set of features to the C++ language! Use of these new features is entirely optional -- but you will undoubtedly find some of them helpful. The prior tutorials have all been updated to be C++11 compliant.
The goals and designs of C++11
Bjarne Stroustrup characterized the goals of C++11 as such:
- Build on C++’s strengths -- rather than trying to extend C++ to new areas where it may be weaker (eg. Windows applications with heavy GUI), focus on making it do what it does well even better.
- Make C++ easier to learn, use, and teach -- provide functionality that makes the language more consistent and easier to use.
To that end, the committee that put the language together tried to obey the following general principles:
- Maintain stability and compatibility with older versions of C++ and C wherever possible. Programs that worked under C++03 should generally still work under C++11.
- Keep the number of core language extensions to a minimum, and put the bulk of the changes in the standard library (an objective that wasn’t met very well with this release)
- Focus on improving abstraction mechanisms (classes, templates) rather than adding mechanisms to handle specific, narrow situations.
- Add new functionality for both novices and experts. A little of something for everybody!
- Increase type safety, to prevent inadvertent bugs.
- Improve performance and allow C++ to work directly with hardware.
- Consider usability and ecosystem issues. C++ needs to work well with other tools, be easy to use and teach, etc…
C++11 isn’t a large departure from C++03 thematically, but it did add a huge amount of new functionality.
Major new features in C++11
For your interest, here’s a list of the major features that C++11 adds. Note that this list is not comprehensive, but rather intended to highlight some of the key features of interest.
- auto (6.14 -- The auto keyword)
- char16_t and char32_t and new literals to support them (no tutorial yet)
- constexpr (4.14 -- Const, constexpr, and symbolic constants)
- decltype (no tutorial yet)
- default specifier (no tutorial yet)
- Delegating constructors (11.8 -- Overlapping and delegating constructors)
- delete specifier (13.14 -- Converting constructors, explicit, and delete)
- Enum classes (8.3 -- Enum classes)
- Extern templates (no tutorial yet)
- Lambda expressions (10.15 -- Introduction to lambdas (anonymous functions)) and captures (10.16 -- Lambda captures)
- long long int (4.3 -- Object sizes and the sizeof operator)
- Move constructor and assignment (M.3 -- Move constructors and move assignment)
- Noexcept specifier (quick mention in 20.4 -- Uncaught exceptions and catch-all handlers)
- nullptr (9.9 -- Null pointers)
- override and final specifiers(18.3 -- The override and final specifiers, and covariant return types)
- Range-based for statements (9.19 -- For-each loops)
- r-value references (M.2 -- R-value references)
- static_assert (7.17 -- Assert and static_assert)
- std::initializer_list (16.7 -- std::initializer_list)
- Trailing return type syntax (6.14 -- The auto keyword)
- Type aliases (6.13 -- Typedefs and type aliases)
- typedef can now typedef template classes
- Uniform initialization (4.1 -- Introduction to fundamental data types)
- User-defined literals (no tutorial yet)
- Variadic templates (no tutorial yet)
- >> will now properly be interpreted as closing a template object
There are also many new classes in the C++ standard library available for use.
- Better support for multi-threading and thread-local storage (no tutorial yet)
- Hash tables (no tutorial yet)
- Random number generation improvements (basic discussion in 8.5 -- Random number generation)
- Reference wrappers (18.9 -- Object slicing)
- Regular expressions (no tutorial yet)
- std::auto_ptr has been deprecated (M.1 -- Intro to smart pointers and move semantics)
- std::tuple (quick mention at 10.5 -- Returning values by value, reference, and address)
- std::unique_ptr (M.6 -- std::unique_ptr)
![]() |
![]() |
![]() |
Hi Alex!
I am wondering if there is a chance to introduce the multithreading module in your tutorial in this year?
Regards,
Rafal
Hi,
Your all concepts are well explained in deeper and detailed. Each time i read, I get more knowledge. So thank you for that.
I would like you to make a tutorial on multithreading. With all the example of new functions supported.
Thanks! It's on the to-do list.
Hi Alex,
Thank you so much for the entire website, it is an ideal reference for beginners, and I benefited a lot from learning. Would you please make a tutorial sooner for lambdas?
You wrote "char16_t and char_32t and new literals to support them (no tutorial yet)". I do believe that you meant not "char_32t" but "char32_t".
Indeed. Thanks!
Variatic templates -> Variadic templates
dhanks for pointing out this error!
:P
It's thanks Xd
Hey Alex,
Kudos for maintaining this website for so long! I refreshed my C++ knowledge by reading your material and love how crisp and concise the content is. I see that you have a couple of items above marked as 'no tutorial yet'. Is there a contribution mechanism in place to help you create some of the tutorials? Maybe setup a github repo so we can open PR's for certain pending topics?
There's no external contribution mechanism in place currently. I've dabbled with that in the past but it's never worked out well. Primarily, I don't have a good way to reward those who contribute, so there's no incentive (other than returning the good will) for people to spend the time. It would be unfair for me to monetize other people's content and not give them a cut, but I don't have an infrastructure in place for that.
Hello Alex, thanks for all the amazing tutorials here. I don't know the site for too long, so if I can ask, how long does it take you to make a new tutorial? Can we expect any tutorials soon? Are all topics pre-C++11 covered already? And would it be possible to rewrite all of standard library by myself?
Best regards, Mates
New tutorials take a fair amount of time to write (generally 3 to 5 solid working sessions). Writing the core material tends to take 1 to 2 sessions, then another 1 to 2 sessions to think up, implement, and test examples that demonstrate the material, and then another day for review, polish, and edits. Creating quiz questions takes even longer.
Also answering random questions takes a lot of time that would otherwise go into writing new material. I wouldn't expect too many new tutorials -- I'm slammed at work and home right now. Most of the pre-C++11 functionality has been covered at this point, minus the standard library which is huge.
Not sure what you mean by "rewrite all of the standard library by myself" -- you mean write your own classes that do the same thing? You could, but I wouldn't advise it. Why reinvent the wheel?
Thanks for your answer! Regarding the standard library, I meant more like whether it is pure-C++, as I don't understand how some classes are implemented, for example std::initializer_list. Also, how long is 'solid working session'?
The details about how the standard library is implemented (e.g. which algorithms they use) is compiler-specific. However, the interface that you use is consistent, so what you really need to understand is how to use the classes properly, not how they're implemented.
A working session for me is a good uninterrupted 3-4 hours. Now that I have 2 young children, finding uninterrupted blocks that long doesn't happen very often. :(
Alex? Which is the best WEBSITE or BOOK to learn graphic desigining in C++ (basic to advanced) ?
Thanks in Advance :)
Waiting for your Reply.....
I have no idea. :)
Hello Hardik,
If you are a beginner then i would suggest you visit udacity.com. They have a course name C++ for programmers.
Hope this helps you.
Regards,
Vikas
Have you considered making a similar page for C++14? I know it wasn't really a big release (at least in comparison), but I think it would be useful for reference if nothing else.
Yup, considered. Just haven't gotten to it yet. :) Thanks for reminding me that I should get around to this eventually.
hi alex,
we are looking forward (a long time) topics that are not tutorial yet. please don't forget us :) especially threads and lambda.
hi Alex, after reading all of this material, what should I do then to master cpp, any recomendation ?
Thanks before, this tutorial make a lot of sense
Put your knowledge into practice. Write lots of programs. Learn something new (e.g. graphical applications in C++).
okay I'll do it, thanks for this great tutorial !!!
You should really consider writing yourself some tutorial on graphical applications. While each major package out there already has extensive tutorials, let me say that I find your approach quite unique and very valuable, as it is both complete and meaningful in the path it follows trough the different topics. When following your tutorial, I had to go back only once, for an example using a const pointer to a c-style string (which I simply forgot it has static attribute and doesn't go out of scope, but that was eventually explained in a comment http://www.learncpp.com/cpp-tutorial/121-pointers-and-references-to-the-base-class-of-derived-objects/#comment-262221). This is something that everybody would be pleased to see applied to any possible programming scenario. I recognize the caducity of any information related to some library with respect to a programming language (still, C++ is not exactly steady with respect to, say, Fortran), but if you mix that with design patterns (as per other requests), that's something that is going to have absolute value. Just look at how bad are all the books on Qt, for example.
I've definitely thought about it. But there's still so much from fundamental C++ (and especially the standard library) that warrants exploration and has broader application... so I probably won't get to this anytime soon. :(
Looking forward to a possible tutorial on lambdas, because I can't for the life of me wrap my head around them.
It's on my to-do but I'm not expecting to get to it very soon. :(
Ah, no hurries!
By the way, I've been wanting to let you know that, being self taught, this site has helped me immensely and I wanted to thank you. Your work is a godsend, man!
You're welcome. Glad you've found it useful!
Hi Alex,
Can you also please create the tutorial for design patterns ..
As i love your tutorials as it gives me in depth information of topics
Regards,
Mehul.
At some point I'll probably dig into design patterns, but since they're not specific to C++ they're lower on my priority list.
I dont see smart pointer here. It is quite a topic in c++11.
Yes, I haven't written those articles yet. They're on my to-do list.
where can we start to learn android programing or smart phone programng? what do you recommend to learn? windows 7,8, android, ois,?? whats next? thanks
Good work by this site.
Please provide information in Design patterns like
(Singleton, Abstract Factory, Builder, Factory methods, Template Method, Observer, Adapter, Facade) with good examples
I am waiting for above information.
Awesome, was waiting for this!