{"id":80687,"date":"2021-05-03T09:00:36","date_gmt":"2021-05-03T03:30:36","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=80687"},"modified":"2021-05-03T09:00:36","modified_gmt":"2021-05-03T03:30:36","slug":"introduction-to-cpp-tutorial","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/introduction-to-cpp-tutorial\/","title":{"rendered":"Introduction to C++ | C++ Basics Tutorial"},"content":{"rendered":"<p><span style=\"font-weight: 400\">Hey there! It takes courage to start learning a new programming language and we at TechVidvan will be with you at every step. Let\u2019s first introduce you to the world of C++ and what makes it a world-famous language. <\/span><\/p>\n<p><span style=\"font-weight: 400\">Kudos if you know a thing or two about C, which will make your journey to learn Cpp much easier. But, even if you are not familiar with the C language don\u2019t worry, we will begin with C++ from the very start.\u00a0<\/span><\/p>\n<h3>History of C++<\/h3>\n<p>In 1979, a Danish Computer Scientist, Bjarne Stroustrup at Bell Labs began working on \u201cC with Classes\u201d and as the name suggests it is a superset of C. While working on his Ph.D. Thesis, he came across this language Simula, and found out that it had features that were helpful for large software implementations, but it was slow. He then aimed towards making a language as efficient and fast as C but filled with features as useful as Simula.<\/p>\n<p>In 1982, he began developing a successor to \u201cC with Classes\u201d and named it \u201cC++\u201d, \u201c++\u201d being the increment operator. Features like operator and method overloading, virtual functions, single-line comments, references, constants, and many more added alongside.<\/p>\n<h3>What is C++?<\/h3>\n<p>C++ is a cross-platform and intermediate\/mid-level programming language that was developed as an advanced model to C language. Since C was a low-level programming language it didn\u2019t possess many features, which were then rendered in C++ (like OOPS, Error Handling, Operator Overloading, etc.).<\/p>\n<h3>Amazing C++ Facts<\/h3>\n<p><span style=\"font-weight: 400\">Here are some amazing facts about C++ that might interest you:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">The word C++ refers to the nature of the occurrence of changes from C. &#8220;++&#8221; is a C increment operator.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">C++ as one of the leading languages is behind the development of all kinds of technical and commercial software.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">C++ introduces Object-Oriented Programming, which is not in C. Like many other things, C++ supports four main features of OOP: encapsulation, polymorphism, inheritance, and abstraction.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">C++ received OOP features from Simula67 Programming language.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">A function is a minimum requirement for the C ++ system to work. (At least the main function ())<\/span><\/li>\n<\/ul>\n<h3>Syntax of C++ Programming<\/h3>\n<p>Let us look at a simple code that prints \u201cWelcome to TechVidvan!\u201d<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include&lt;iostream&gt;\nusing namespace std;\n\nint main()\n{\n    cout &lt;&lt;\"Welcome to TechVidvan!\";\n    return 0;\n}\n<\/pre>\n<p><span style=\"font-weight: 400\">To understand the code snippet, we will have to look at it line by line:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">The C++ language defines the preprocessors or header files needed in the program. For this program, the header required is &lt;iostream&gt;.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">The <\/span><span style=\"font-weight: 400\">using<\/span> <span style=\"font-weight: 400\">namespace<\/span> <span style=\"font-weight: 400\">std<\/span><span style=\"font-weight: 400\">; <\/span><span style=\"font-weight: 400\">asks the compiler to use the std namespace.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">The program execution will fail if there\u2019s no main() function. <\/span><span style=\"font-weight: 400\">int<\/span> <span style=\"font-weight: 400\">main<\/span><span style=\"font-weight: 400\">()<\/span><span style=\"font-weight: 400\"> is the main function where program execution begins.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">The <\/span><span style=\"font-weight: 400\">cout<\/span><span style=\"font-weight: 400\"> &lt;&lt; <\/span><span style=\"font-weight: 400\">&#8220;Welcome to TechVidvan!&#8221;<\/span><span style=\"font-weight: 400\">;<\/span><span style=\"font-weight: 400\"> is where we achieve the purpose of this program. The message gets printed in this line.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">But, we are not done yet without <\/span><span style=\"font-weight: 400\">return<\/span> <span style=\"font-weight: 400\">0<\/span><span style=\"font-weight: 400\">;<\/span><span style=\"font-weight: 400\"> the main() function won\u2019t terminate and the execution will fail.<\/span><\/li>\n<\/ul>\n<h3>Why choose C++ over C?<\/h3>\n<p><span style=\"font-weight: 400\">To date, C is a dominant language and doesn\u2019t seem to be retiring anytime soon. But, given the advances in microcontroller hardware and optimization, it might be time that developers and students start considering C++ for their perusal. <\/span><\/p>\n<p><span style=\"font-weight: 400\">Listed below are some of the reasons:\u00a0<\/span><\/p>\n<p><b>1. Modern OOP Techniques:<\/b><span style=\"font-weight: 400\"> C language invented 50 years ago, lacks everything that newer programming language has, such as OOP concepts like Encapsulation, Inheritance, and Polymorphism. <\/span><\/p>\n<p><span style=\"font-weight: 400\">In C++, we can use these techniques and make the code much more efficient and increase its readability as well as re-usability.\u00a0<\/span><\/p>\n<p><b>2. Microcontrollers<\/b><span style=\"font-weight: 400\">: Compiler and toolchain support for microcontrollers has been frequently updated by the tool providers. Beyond this, microcontrollers have begun to add hooks to the tools, such that it is easier to develop C++ applications.<\/span><\/p>\n<p><b>3. Exception Handling:<\/b><span style=\"font-weight: 400\"> In C, error\/exception handling has been lacking all the while. Whereas, in C++ exception handling makes the language even superior.<\/span><\/p>\n<p><b>4. Special Methods: <\/b><span style=\"font-weight: 400\">The concept of constructors (and their different types) and destructors for objects makes C++ worth switching.<\/span><\/p>\n<p><b>5. Better Macro:<\/b><span style=\"font-weight: 400\"> In C, we use Macros and in C++ we use Inline Functions, which makes the entire function body act like a Macro.<\/span><\/p>\n<p><b>6. Advanced Features:<\/b><span style=\"font-weight: 400\"> In C++ there is no restriction for variable declaration i.e. we can declare them anywhere as long as the declaration is before the actual use. Type Checking is stronger in C++.<\/span><\/p>\n<h3>Features of C++ Language<\/h3>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/05\/Features-of-C-Programming.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-80693\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/05\/Features-of-C-Programming.jpg\" alt=\"Features of C++ Programming\" width=\"1100\" height=\"628\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400\">C++ is one of the most widely used programming languages for multiple purposes. Thus mentioned below are some of the features which give it the upper hand over the other programming languages:\u00a0<\/span><\/p>\n<p><b>1. Mid-level language:<\/b><span style=\"font-weight: 400\"> Being a mid-level language, C++ comprises advantages of both high-level and low-level languages. <\/span><\/p>\n<p><span style=\"font-weight: 400\">For example, it can be used for drivers and kernels (low-level language features), as well as for games and desktop applications (high-level language features).<\/span><\/p>\n<p><b>2. Cross-Platform<\/b><span style=\"font-weight: 400\">: C++ can run on many platforms, hence team members with different machines can code together on a project. We can also compile C++ to numerous platforms, giving it an advantage over other programming languages like C# which is now restricted to Windows.<\/span><\/p>\n<p><b>3. Gives more control:<\/b><span style=\"font-weight: 400\"> C++ gives users more control over system performance and memory management. Hence, there is no garbage collection like in Java.\u00a0<\/span><\/p>\n<p><b>4. Advanced Concepts: <\/b><span style=\"font-weight: 400\">Concepts like Object-Oriented Programming, gives us a clear and precise understanding of low-level implementations of polymorphism.\u00a0<\/span><\/p>\n<p><b>5. Flexibility:<\/b><span style=\"font-weight: 400\"> OOP, Functional and Procedural are all supported in C++, making it flexible to switch styles as per need for different projects. Likewise, we can even combine different styles for the same project.\u00a0<\/span><\/p>\n<p><b>6. Easy to learn:<\/b><span style=\"font-weight: 400\"> C++ is really similar to C# and Java, which makes it easier to switch to and from the other programming languages.<\/span><\/p>\n<p><b>7. Ample library support: <\/b><span style=\"font-weight: 400\">Besides 3rd party libraries for fast and swift development, C++ also supports libraries for data structures and algorithms.<\/span><\/p>\n<p><b>8. Faster Execution:<\/b><span style=\"font-weight: 400\"> Being a compiled and procedural language, source code written in C++ shine in execution. Garbage collection and dynamic typing along with many features slow down the execution in modern languages.\u00a0\u00a0<\/span><\/p>\n<h3>Applications of C++ Programming Language<\/h3>\n<p><span style=\"font-weight: 400\">C++ is an extensively used programming language also used for building and developing real-life applications, while some of them are:<\/span><\/p>\n<p><b>1. Operating Systems: <\/b><span style=\"font-weight: 400\">C++ language is often used in writing many major Operating Systems including Windows, Linux, and macOS.\u00a0<\/span><\/p>\n<p><b>2. Newer programming languages:<\/b><span style=\"font-weight: 400\"> Despite being an extension of C, C++ is also used to develop many programming languages like C#, Java, JavaScript, PHP, Python, and many more. Thus, helped to bloom the software development industry.<\/span><\/p>\n<p><b>3. Games: <\/b><span style=\"font-weight: 400\">As discussed earlier, we know that C++ is faster and it allows speedy execution which helps developers to utilize the CPU for thorough functions. Effectively, C++ helps developing gaming engines as it gives better control over hardware.<\/span><\/p>\n<p><b>4. Graphics User Interface Applications:<\/b><span style=\"font-weight: 400\"> C++ is also used to build most of the GUI Based applications which we use almost daily. Adobe Systems, Windows Media Player, and Blender being a few of them.<\/span><\/p>\n<p><b>5. Database Software:<\/b><span style=\"font-weight: 400\"> In the world of Database Management, engines like MySQL, Redis, Postgres, and MongoDB are the most popular. It would be interesting to know that they were written in C++.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Besides, all this C++ has also helped us with the widely used browsers (Mozilla and Chrome), banking applications (Infosys Finacle), and Cloud\/Distributed System (Bloomberg).<\/span><\/p>\n<h3>Keywords in C++<\/h3>\n<p>Just like any other programming language, C++ has keywords or \u201creserved words\u201d whose meanings are already explained to the compiler. Keywords are those words that have a predefined meaning, hence we can not use them as identifiers.<\/p>\n<p>C++ language has 75 keywords:<\/p>\n<table>\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400\">and<\/span><\/td>\n<td><span style=\"font-weight: 400\">continue<\/span><\/td>\n<td><span style=\"font-weight: 400\">if<\/span><\/td>\n<td><span style=\"font-weight: 400\">public<\/span><\/td>\n<td><span style=\"font-weight: 400\">try<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">and_eq<\/span><\/td>\n<td><span style=\"font-weight: 400\">default<\/span><\/td>\n<td><span style=\"font-weight: 400\">inline<\/span><\/td>\n<td><span style=\"font-weight: 400\">register<\/span><\/td>\n<td><span style=\"font-weight: 400\">typedef<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">asm<\/span><\/td>\n<td><span style=\"font-weight: 400\">delete<\/span><\/td>\n<td><span style=\"font-weight: 400\">int<\/span><\/td>\n<td><span style=\"font-weight: 400\">reinterpret_cast<\/span><\/td>\n<td><span style=\"font-weight: 400\">typeid<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">auto<\/span><\/td>\n<td><span style=\"font-weight: 400\">do<\/span><\/td>\n<td><span style=\"font-weight: 400\">typename<\/span><\/td>\n<td><span style=\"font-weight: 400\">long<\/span><\/td>\n<td><span style=\"font-weight: 400\">return<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">bitand<\/span><\/td>\n<td><span style=\"font-weight: 400\">double<\/span><\/td>\n<td><span style=\"font-weight: 400\">mutable<\/span><\/td>\n<td><span style=\"font-weight: 400\">short<\/span><\/td>\n<td><span style=\"font-weight: 400\">uchar_t<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">bitor<\/span><\/td>\n<td><span style=\"font-weight: 400\">dynamiccast<\/span><\/td>\n<td><span style=\"font-weight: 400\">namespace<\/span><\/td>\n<td><span style=\"font-weight: 400\">signed<\/span><\/td>\n<td><span style=\"font-weight: 400\">union<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">bool<\/span><\/td>\n<td><span style=\"font-weight: 400\">else<\/span><\/td>\n<td><span style=\"font-weight: 400\">new<\/span><\/td>\n<td><span style=\"font-weight: 400\">sizeof<\/span><\/td>\n<td><span style=\"font-weight: 400\">unsigned<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">break<\/span><\/td>\n<td><span style=\"font-weight: 400\">enum<\/span><\/td>\n<td><span style=\"font-weight: 400\">not<\/span><\/td>\n<td><span style=\"font-weight: 400\">state_cast<\/span><\/td>\n<td><span style=\"font-weight: 400\">using<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">case<\/span><\/td>\n<td><span style=\"font-weight: 400\">explicit<\/span><\/td>\n<td><span style=\"font-weight: 400\">not_eq<\/span><\/td>\n<td><span style=\"font-weight: 400\">static<\/span><\/td>\n<td><span style=\"font-weight: 400\">virtual<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">catch<\/span><\/td>\n<td><span style=\"font-weight: 400\">extern<\/span><\/td>\n<td><span style=\"font-weight: 400\">operator<\/span><\/td>\n<td><span style=\"font-weight: 400\">struct<\/span><\/td>\n<td><span style=\"font-weight: 400\">void<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">char<\/span><\/td>\n<td><span style=\"font-weight: 400\">false<\/span><\/td>\n<td><span style=\"font-weight: 400\">Or<\/span><\/td>\n<td><span style=\"font-weight: 400\">switch<\/span><\/td>\n<td><span style=\"font-weight: 400\">volatile<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">class<\/span><\/td>\n<td><span style=\"font-weight: 400\">float<\/span><\/td>\n<td><span style=\"font-weight: 400\">or_eq<\/span><\/td>\n<td><span style=\"font-weight: 400\">template<\/span><\/td>\n<td><span style=\"font-weight: 400\">wchar_t<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">compl<\/span><\/td>\n<td><span style=\"font-weight: 400\">for<\/span><\/td>\n<td><span style=\"font-weight: 400\">overload<\/span><\/td>\n<td><span style=\"font-weight: 400\">this<\/span><\/td>\n<td><span style=\"font-weight: 400\">while<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">const<\/span><\/td>\n<td><span style=\"font-weight: 400\">friend<\/span><\/td>\n<td><span style=\"font-weight: 400\">throw<\/span><\/td>\n<td><span style=\"font-weight: 400\">private<\/span><\/td>\n<td><span style=\"font-weight: 400\">xor<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">constcast<\/span><\/td>\n<td><span style=\"font-weight: 400\">goto<\/span><\/td>\n<td><span style=\"font-weight: 400\">protected<\/span><\/td>\n<td><span style=\"font-weight: 400\">true<\/span><\/td>\n<td><span style=\"font-weight: 400\">xor_eq<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>Comments in C++<\/h3>\n<p><span style=\"font-weight: 400\">Students, developers, and even teachers sometimes need to explain the code snippets for that C++ supports comments.<\/span><\/p>\n<p><span style=\"font-weight: 400\">There are 2 types of comments :<\/span><\/p>\n<p><strong>1. Single-line comments (\/\/)<\/strong><\/p>\n<p><span style=\"font-weight: 400\">A single-line comment starts with two front slashes and continues to the end of the line.<\/span><\/p>\n<p><strong>2. Multi-line comments (\/* &#8230;.. *\/)<\/strong><\/p>\n<p><span style=\"font-weight: 400\">Multi-line comments or block comments are used when the explanation isn\u2019t short and writing it on one continued line makes it unreadable. They begin with \u201c \/* \u201d and end with \u201c *\/ \u201c.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">Just to be clear, comments are not a part of the program and the compiler ignores them, so even if the comments have errors they won\u2019t be detected.<\/span><\/p>\n<h3>Escape Sequences in C++<\/h3>\n<p>Escape sequences are non-printing characters used to control the printing behavior of the display stream objects, hence are also known as control characters. These characters are not printed in the output. They are prefixed with a backslash and a character to control the printing behavior. They can be inserted in any position of the string.<\/p>\n<p>Some of the escape sequences along with their purpose are mentioned below:<\/p>\n<ul>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">\\a<\/span><span style=\"font-weight: 400\"> &#8211; Bell<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">\\n<\/span><span style=\"font-weight: 400\"> &#8211; New line<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">\\r<\/span><span style=\"font-weight: 400\"> &#8211; Carriage return<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">\\b<\/span><span style=\"font-weight: 400\"> &#8211; Backspace<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">\\f<\/span><span style=\"font-weight: 400\"> &#8211; Formfeed<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">\\t<\/span><span style=\"font-weight: 400\"> &#8211; Horizontal tab<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">\\<\/span><span style=\"font-weight: 400\">&#8220;<\/span><span style=\"font-weight: 400\"> &#8211; Quotation mark<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">\\v<\/span><span style=\"font-weight: 400\"> &#8211; Vertical tab<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">\\&#8217;<\/span><span style=\"font-weight: 400\"> &#8211; Apostrophe<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">\\\\<\/span><span style=\"font-weight: 400\"> &#8211; Backslash<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">\\?<\/span><span style=\"font-weight: 400\"> &#8211; Question mark<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">\\<\/span><span style=\"font-weight: 400\">0<\/span><span style=\"font-weight: 400\"> &#8211; Null<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400\">Let\u2019s learn the concept of escape sequence by implementing them:<\/span><\/p>\n<p><span style=\"font-weight: 400\">For example, take the previous code\u00a0<\/span><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include&lt;iostream&gt;\nusing namespace std;\n\nint main()\n{\n    cout &lt;&lt;\"Welcome to TechVidvan!\";\n    return 0;\n}\n<\/pre>\n<p><span style=\"font-weight: 400\">Now, if you want to print \u201cWelcome to\u201d and \u201cTechVidvan!\u201d in separate lines, just simply insert the escape sequence \u201c\\n\u201d in the middle of the string.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include&lt;iostream&gt;\nusing namespace std;\n\nint main()\n{\n    cout &lt;&lt;\"Welcome to \\nTechVidvan!\";\n    return 0;\n}\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">\n<p>Welcome toTechVidvan<\/p>\n<\/div>\n<h4>Advantages of Programming in C++<\/h4>\n<ul>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">C++ is the fastest and most efficient language.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">C++ has a variety of uses and that is why learning a language makes it easier to understand the concept of OOP which is very important for the IT industry.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Learning C++ gives a good foundation and makes it easier to learn other programming languages.<\/span><\/li>\n<\/ul>\n<h4>Disadvantages of C++ programming<\/h4>\n<ul>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">C ++ is often difficult to identify.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Error messages in C ++ can be extended and it is often difficult to correct the error.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Accessing libraries in C++ can be a very tedious job.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">C++ source code is always prone to errors as type-checking is not present.<\/span><\/li>\n<\/ul>\n<h3>Libraries in C++<\/h3>\n<p><span style=\"font-weight: 400\">Standard C ++ programs are divided into three main sections:<\/span><\/p>\n<p><span style=\"font-weight: 400\">1. The primary library includes data types, variables and text, etc.<\/span><\/p>\n<p><span style=\"font-weight: 400\">2. A typical library includes a set of tasks that control cables, files, etc.<\/span><\/p>\n<p><span style=\"font-weight: 400\">3. The Standard Template Library (STL) includes a variety of methods that use data structure.<\/span><\/p>\n<h3>Summary<\/h3>\n<p>In this C++ tutorial, we learned the basics of C++ including the syntax of a C++ program, the features and applications along with advantages and disadvantages. We even got to know about the escape sequence, standard libraries, and the keywords in C++.<\/p>\n<p>This C++ tutorial from TechVidvan gets followed by various other topics in C++. Hopefully, this article helped you build a foundation that will make it easier to understand the following topics.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey there! It takes courage to start learning a new programming language and we at TechVidvan will be with you at every step. Let\u2019s first introduce you to the world of C++ and what&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":80694,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3405],"tags":[3398,3399,3400,3401,3402,3403,3404,3406,3407,3408,3409,3410],"class_list":["post-80687","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cpp","tag-applications-of-c","tag-c-features","tag-c-advantages","tag-c-disadvantages","tag-c-introduction","tag-c-programming-language","tag-c-tutorial","tag-commnets-in-c","tag-escape-sequences-in-c","tag-keywords-in-c","tag-libraries-in-c","tag-why-learn-c"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Introduction to C++ | C++ Basics Tutorial - TechVidvan<\/title>\n<meta name=\"description\" content=\"C++ is a middle-level programming language developed by Bjarne Stroustrup starting in 1979 at Bell Labs. Learn more in this C++ tutorial..\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/introduction-to-cpp-tutorial\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Introduction to C++ | C++ Basics Tutorial - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"C++ is a middle-level programming language developed by Bjarne Stroustrup starting in 1979 at Bell Labs. Learn more in this C++ tutorial..\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/introduction-to-cpp-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-05-03T03:30:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/05\/Introduction-to-C.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Introduction to C++ | C++ Basics Tutorial - TechVidvan","description":"C++ is a middle-level programming language developed by Bjarne Stroustrup starting in 1979 at Bell Labs. Learn more in this C++ tutorial..","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/techvidvan.com\/tutorials\/introduction-to-cpp-tutorial\/","og_locale":"en_US","og_type":"article","og_title":"Introduction to C++ | C++ Basics Tutorial - TechVidvan","og_description":"C++ is a middle-level programming language developed by Bjarne Stroustrup starting in 1979 at Bell Labs. Learn more in this C++ tutorial..","og_url":"https:\/\/techvidvan.com\/tutorials\/introduction-to-cpp-tutorial\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2021-05-03T03:30:36+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/05\/Introduction-to-C.jpg","type":"image\/jpeg"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/introduction-to-cpp-tutorial\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/introduction-to-cpp-tutorial\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Introduction to C++ | C++ Basics Tutorial","datePublished":"2021-05-03T03:30:36+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/introduction-to-cpp-tutorial\/"},"wordCount":1804,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/introduction-to-cpp-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/05\/Introduction-to-C.jpg","keywords":["Applications of C++","C features","C++ Advantages","C++ disadvantages","C++ Introduction","c++ programming Language","C++ Tutorial","Commnets in C++","Escape Sequences in C++","Keywords in C","Libraries in C++","Why Learn C"],"articleSection":["C++ Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/introduction-to-cpp-tutorial\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/introduction-to-cpp-tutorial\/","url":"https:\/\/techvidvan.com\/tutorials\/introduction-to-cpp-tutorial\/","name":"Introduction to C++ | C++ Basics Tutorial - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/introduction-to-cpp-tutorial\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/introduction-to-cpp-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/05\/Introduction-to-C.jpg","datePublished":"2021-05-03T03:30:36+00:00","description":"C++ is a middle-level programming language developed by Bjarne Stroustrup starting in 1979 at Bell Labs. Learn more in this C++ tutorial..","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/introduction-to-cpp-tutorial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/introduction-to-cpp-tutorial\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/introduction-to-cpp-tutorial\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/05\/Introduction-to-C.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/05\/Introduction-to-C.jpg","width":1200,"height":628},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/introduction-to-cpp-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Introduction to C++ | C++ Basics Tutorial"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/80687","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=80687"}],"version-history":[{"count":0,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/80687\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/80694"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=80687"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=80687"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=80687"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}