DEV Community

Cover image for Modern C++: An Introduction
Swastik Baranwal
Swastik Baranwal

Posted on • Edited on

Modern C++: An Introduction

Most people think that they know C++ which is used in production level as they are taught C++ in their syllabus of their university/college. But they mostly do not know what standard of C++ they are taught. They are taught C++ 89 i.e. CFront 2.0. Students are told to use Turbo C++ as IDE to learn C++ in university because it is or was a great IDE in it's age. As the academic syllabus takes a lot of time to change and people don't know that it is outdated mostly trend to learn old coding styles and deprecated features.

What is Modern C++?

Modern C++ stands for C++ that is based on C++11, C++14, and C++17 C++20 and future versions.

With C++11 we had a revolution. That revolutions became with C++14 and will become with C++17 to an evolution. An overview on the time line of C++ features which makes my point clear.

Modern C++ not only enhances the usability of the C++ itself, but the modification of the auto keyword semantics gives more confidence in manipulating extremely complex template types. At the same time, a lot of enhancements have been made to the language at runtime. The emergence of Lambda expressions has made C++ have the "closure" feature of "anonymous functions", which is almost in modern programming languages ​​(such as Python/Swift/.. It has become commonplace, and the emergence of rvalue references has solved the problem of temporary object efficiency that C++ has long been criticized for.

Deprecated Features

  • The string literal constant is no longer allowed to be assigned to a char *. If you need to assign and initialize a char * with a string literal constant, you should use const char * or auto.
char *str = "hello world!"; // A deprecation warning will appear
Enter fullscreen mode Exit fullscreen mode
  • C++98 exception description, unexpected_handler, set_unexpected() and other related features are deprecated and should use noexcept.

  • auto_ptr is deprecated and unique_ptr should be used.

  • register keyword is deprecated and can be used but no longer has any practical meaning.

  • bool can no longer be incremented

  • If a class has a destructor, the properties for which it generates copy constructors and copy assignment operators are deprecated.

  • C language style type conversion is deprecated (ie using (convert_type)) before variables, and static_cast, reinterpret_cast, const_cast should be used for type conversion.

  • In particular, some of the C standard libraries that can be used are now deprecated in the latest C++ standard, such as <ccomplex>, <cstdalign>, <cstdbool> and <ctgmath>.

  • Many more that I cannot remember.

Resources of learning Modern C++

List of Posts made by me

Github

All the code used in my articles are available on Delta456/modern-cpp-series.


Top comments (5)

Collapse
 
jamoyjamie profile image
Jamie Read

I chuckled a little at bool can no longer be incremented!

Part of me really wants to know the backstory to that and why (if purposefully) that was ever possible!

Collapse
 
gothistanic profile image
Aymen Chehaider

hhh, I did too and was wondering if anyone posted a comment on that. And yes I was not alone :D

Collapse
 
albertobsd profile image
Luis Alberto

Just to say, that Turbo C was the ugliest IDE and to be honest I dislike it. I use gcc and g++ to compile code what kind of IDE or Environment do you prefer?

Collapse
 
delta456 profile image
Swastik Baranwal

g++ and VSCode for me

Collapse
 
delta456 profile image
Swastik Baranwal

Heads up! I have updated the main post and I will continue my series when C++ 20 is out because there are gonna be many new features and major changes. Hope you are looking forward to it!