Professional Documents
Culture Documents
C++ Slides
C++ Slides
Module V
Programing with C++
5
What is C++
C++ is a programming language.
• A standardized, intermediate-level, general-purpose,
object-oriented, and compiled language.
• Created by Bjarne Stroustrup (1983) as an extension to
a C programming language.
• Still, C++ evolved to be a completely different
programming language.
• C++ is accompanied by a set of functions and
containers called the C++ Standard-Library.
73
5
74
5
75
5
• Code editor (or IDE) with C++ extension C++ Dev tools
• Visual Studio Code for this Course
• Compiler (for generating a binary executable)
• Mingw (gcc),
• Clang llvm (Low level virtual machine )(Clang++)
• Additionally you can use
• Msvc (Microsoft visual studio)
76
5
• Code editor (or IDE) with C++ extension C++ Dev tools
• Visual Studio Code for this Course
• Compiler (for generating a binary executable)
• Mingw (gcc compiler), - Main compiler for this course
• Clang llvm (Low level virtual machine )(Clang++
compiler)
• Additionally you can use
• Msvc (Microsoft visual studio)
77
5
Installing Compilers
• Install the latest version of a compiler always
• Visit https://winlibs.com to download both gcc & Clang
compilers
78
5
79
5
80
5
81
5
Installing Compilers
82
5
Installing Compilers
83
5
Installing Compilers
84
5
Installing Compilers
85
5
Installing Compilers
86
5
87
5
Setting up Vs Code
• Visit https://code.visualstudio.com to download the latest
Visual studio code editor of your OS
88
5
Setting up Vs Code
• Run the downloaded file and open it after the
installation has completed
89
5
90
5
91
5
• Open Vs Code
• Create a “source.cpp” file and copy this code as a test Connecting Vs Code
code with the compilers
92
5
93
5
94
5
95
5
Configuring compilers
• For example you can read on how to modify the
tasks.json file for gcc and clang compilers
96
5
97
5
98
5
Testing compilers
• Lastly you need to configure one more last thing to make your
programing easy
• Press Ctr + Shift + p and choose “C++: edit configuration”;
• Set the configs to the compiler of your choice and a
“c_cpp_properties.json”.
• Cool! We are all set and we have a template file
99
5
Testing compilers
100
5
• The function main is the main program entry point, the start First C++ Program
of our program.
• When we run our executable, the code inside the main
function body gets executed.
• A function is of type int and returns a result to the system int main() {}
• The reserved name main is a function name.
• It is followed by a list of parameters inside the parentheses ()
followed by a function body marked with braces {}.
• Braces marking the beginning and the end of a function body
• can also be on separate lines:
101
5
102
5
Explanation
• The #include <iostream> statement includes the iostream First C++ Program
header into our source file via the #include directive.
• The iostream header is part of the standard library.
• We need its inclusion to use the std::cout object,
• also known as a standard-output stream.
int main() {}
• The << operator inserts our Hello World string literal into
that output stream.
• String literal is enclosed in double quotes “”.
• The ; marks the end of the statement.
• Statements are pieces of the C++program that get executed.
• Statements must end with a semicolon ; in C++.
103
5
104