What is C++?
π C++ is a cross-platform language that can be used to create high-performance applications.
π C++ was developed by Bjarne Stroustrup, as an extension to the C language.
π C++ gives programmers a high level of control over system resources and memory.
@c_programming_tut
π C++ is a cross-platform language that can be used to create high-performance applications.
π C++ was developed by Bjarne Stroustrup, as an extension to the C language.
π C++ gives programmers a high level of control over system resources and memory.
@c_programming_tut
Why Use C++
πC++ is one of the world's most popular programming languages.
πC++ can be found in today's operating systems, Graphical User Interfaces, and embedded systems.
πC++ is an object-oriented programming language which gives a clear structure to programs and allows code to be reused, lowering development costs.
πC++ is portable and can be used to develop applications that can be adapted to multiple platforms.
πC++ is fun and easy to learn!
@c_programming_tut
πC++ is one of the world's most popular programming languages.
πC++ can be found in today's operating systems, Graphical User Interfaces, and embedded systems.
πC++ is an object-oriented programming language which gives a clear structure to programs and allows code to be reused, lowering development costs.
πC++ is portable and can be used to develop applications that can be adapted to multiple platforms.
πC++ is fun and easy to learn!
@c_programming_tut
πC++ Getting Started...
βοΈ To start using C++, you need two things:
π§A text editor,
like Notepad,
Sublime Text ,
VS code,
to write C++ code
π§A compiler,
like GCC,
to translate the C++ code into a language that the computer will understand
@c_programming_tut
βοΈ To start using C++, you need two things:
π§A text editor,
like Notepad,
Sublime Text ,
VS code,
to write C++ code
π§A compiler,
like GCC,
to translate the C++ code into a language that the computer will understand
@c_programming_tut
πC++ Install IDE
βοΈAn IDE (Integrated Development Environment) is used to edit AND compile the code.
βοΈPopular IDE's include
Code::Blocks,
Eclipse, and
Visual Studio.
These are all free, and they can be used to both edit and debug C++ code.
Note: Web-based IDE's can work as well, but functionality is limited.
βοΈWe will use Code::Blocks in our tutorial, which we believe is a good place to start.
π₯ You can find the latest version of Codeblocks at
http://www.codeblocks.org/downloads/26
Download the mingw-setup.exe file, which will install the text editor with a compiler.
@c_programming_tut
βοΈAn IDE (Integrated Development Environment) is used to edit AND compile the code.
βοΈPopular IDE's include
Code::Blocks,
Eclipse, and
Visual Studio.
These are all free, and they can be used to both edit and debug C++ code.
Note: Web-based IDE's can work as well, but functionality is limited.
βοΈWe will use Code::Blocks in our tutorial, which we believe is a good place to start.
π₯ You can find the latest version of Codeblocks at
http://www.codeblocks.org/downloads/26
Download the mingw-setup.exe file, which will install the text editor with a compiler.
@c_programming_tut
πC++ Quickstart
βοΈ Let's create our first C++ file.
βοΈ Open Codeblocks and go to File > New > Empty File.
βοΈ Write the following C++ code and save the file as myfirstprogram.cpp (File > Save File as):
@c_programming_tut
βοΈ Let's create our first C++ file.
βοΈ Open Codeblocks and go to File > New > Empty File.
βοΈ Write the following C++ code and save the file as myfirstprogram.cpp (File > Save File as):
@c_programming_tut
π Don't worry if you don't understand the code above -
we will discuss it in detail in later chapters.
βοΈFor now, focus on how to run the code.
βοΈ Then, go to Build > Build and Run to run (execute) the program.
@c_programming_tut
we will discuss it in detail in later chapters.
βοΈFor now, focus on how to run the code.
βοΈ Then, go to Build > Build and Run to run (execute) the program.
@c_programming_tut
π Example explained
βοΈ Line 1: #include <iostream> is a header file library that lets us work with input and output objects, such as cout (used in line 5). Header files add functionality to C++ programs.
βοΈ Line 2: using namespace std means that we can use names for objects and variables from the standard library.
πDon't worry if you don't understand how #include <iostream> and using namespace std works. Just think of it as something that (almost) always appears in your program.
@c_programming_tut
βοΈ Line 1: #include <iostream> is a header file library that lets us work with input and output objects, such as cout (used in line 5). Header files add functionality to C++ programs.
βοΈ Line 2: using namespace std means that we can use names for objects and variables from the standard library.
πDon't worry if you don't understand how #include <iostream> and using namespace std works. Just think of it as something that (almost) always appears in your program.
@c_programming_tut
βοΈ Line 3: A blank line. C++ ignores white space.
βοΈ Line 4: Another thing that always appear in a C++ program, is int main(). This is called a function. Any code inside its curly brackets {} will be executed.
βοΈ Line 5: cout (pronounced "see-out") is an object used together with the insertion operator (<<) to output/print text. In our example it will output "Hello World".
βοΈLine 6: return 0 ends the main function.
βοΈLine 7: Do not forget to add the closing curly bracket } to actually end the main function.
@c_programming_tut
βοΈ Line 4: Another thing that always appear in a C++ program, is int main(). This is called a function. Any code inside its curly brackets {} will be executed.
βοΈ Line 5: cout (pronounced "see-out") is an object used together with the insertion operator (<<) to output/print text. In our example it will output "Hello World".
βοΈLine 6: return 0 ends the main function.
βοΈLine 7: Do not forget to add the closing curly bracket } to actually end the main function.
@c_programming_tut