C++ Programming Course - Beginner to Advanced

freeCodeCamp.org www.youtube.com

Brief Summary

This video is a complete C++ course for beginners. It covers fundamental concepts like variables, data types, operators, statements, functions, and loops. The course also delves into object-oriented programming concepts like classes, inheritance, and polymorphism. The video emphasizes the importance of understanding the C++ memory model and execution model, as well as the use of tools like compilers, IDEs, and debuggers.

  • Learn the fundamentals of C++ programming.
  • Explore object-oriented programming concepts.
  • Understand the C++ memory model and execution model.
  • Learn how to use tools like compilers, IDEs, and debuggers.

Introduction

This video introduces a modern C++ course for beginners. It covers the basics of C++ programming, including procedural programming, object-oriented programming, and advanced features. The course is designed for complete beginners and emphasizes understanding the fundamentals.

Development Tools

This chapter explains the essential tools for C++ development, including editors/IDEs and compilers. The video recommends using Visual Studio Code as the editor for its ease of use, cross-platform compatibility, and support for various tools. It also discusses the role of compilers in transforming C++ code into executable binary formats. The chapter provides detailed instructions on installing Visual Studio Code and various compilers (GCC, Clang, and MSVC) on Windows, Linux, and macOS.

Connecting Visual Studio Code to Compilers

This chapter focuses on connecting Visual Studio Code to the previously installed compilers. It demonstrates how to configure Visual Studio Code to use GCC, Clang, and MSVC compilers for building C++ projects. The chapter uses a simple C++ program to test the compiler's support for C++20 features and provides a template project that can be reused throughout the course.

Compilers on Linux

This chapter covers the installation of C++ compilers on Linux, specifically Ubuntu 20.04. It explains how to install GCC 10 and Clang LLVM using the apt package manager. The chapter also discusses the use of Homebrew for installing the latest version of GCC on Linux.

Visual Studio Code on Linux

This chapter focuses on installing Visual Studio Code on Linux (Ubuntu 20.04). It provides instructions on downloading the Visual Studio Code binary and installing it using the dpkg package manager. The chapter also explains how to install the C/C++ extension for Visual Studio Code on Linux.

Connecting Visual Studio Code to Compilers on Linux

This chapter demonstrates how to connect Visual Studio Code to the previously installed compilers on Linux. It shows how to configure Visual Studio Code to use GCC and Clang compilers for building C++ projects on Ubuntu 20.04. The chapter uses a simple C++ program to test the compiler's support for C++20 features and provides a template project that can be reused throughout the course.

Compilers on macOS

This chapter covers the installation of C++ compilers on macOS. It explains how to install GCC and Clang LLVM using the Homebrew package manager. The chapter also discusses the installation of Xcode and its associated compiler for C++ development on macOS.

Visual Studio Code on macOS

This chapter focuses on installing Visual Studio Code on macOS. It provides instructions on downloading the Visual Studio Code binary and installing it. The chapter also explains how to install the C/C++ extension for Visual Studio Code on macOS.

Connecting Visual Studio Code to Compilers on macOS

This chapter demonstrates how to connect Visual Studio Code to the previously installed compilers on macOS. It explains how to configure Visual Studio Code to use GCC, Clang, and Clang LLVM compilers for building C++ projects.

Online Compilers

This chapter explores the use of online compilers for C++ development. It introduces popular online compilers like OneCompiler, Compiler Explorer, and Coliru, highlighting their features and benefits. The chapter demonstrates how to use these online compilers to test C++ code and share it with others.

First C++20 Program

This chapter guides viewers through writing their first C++20 program. It explains the basic structure of a C++ program, including the #include directive, the main function, and the use of std::cout and std::endl for printing output to the console. The chapter also introduces the spaceship operator (<=>) and demonstrates its use in a simple C++20 program.

Comments in C++

This chapter focuses on comments in C++. It explains the purpose of comments, which are used to add human-readable explanations to C++ code. The chapter covers two types of comments: single-line comments (//) and block comments (/* */). It also emphasizes the importance of using comments judiciously and avoiding excessive commenting.

Errors and Warnings in C++

This chapter discusses errors and warnings in C++ programs. It explains the different types of errors, including compile-time errors, runtime errors, and warnings. The chapter provides examples of each type of error and demonstrates how to identify and fix them.

Statements and Functions in C++

This chapter delves into statements and functions in C++. It explains that statements are the basic units of computation in C++ and must end with a semicolon. The chapter also introduces the concept of functions, which are reusable blocks of code that can take input, perform operations, and return output. It provides examples of different types of functions and demonstrates how to declare, define, and call them.

Input and Output in C++

This chapter focuses on input and output operations in C++. It explains the use of std::cin and std::cout for reading data from the console and writing data to the console, respectively. The chapter also covers the use of std::cerr for printing error messages and std::clog for printing log messages. It demonstrates how to read data with spaces using std::getline and explains the concept of chaining input stream operators.

C++ Execution Model

This chapter explores the C++ execution model, providing a simplified overview of how C++ programs are loaded into memory and executed by the CPU. It explains the concepts of virtual memory, the memory management unit (MMU), and the different sections of the memory map, including the text section, data section, heap, and stack. The chapter also discusses the role of the CPU in executing instructions statement by statement.

C++ Core Language, Standard Library, and STL

This chapter clarifies the differences between the C++ core language, the standard library, and the Standard Template Library (STL). It explains that the core language provides the fundamental building blocks of C++, while the standard library offers a collection of ready-to-use components. The STL is a specialized part of the standard library that provides container types, algorithms, and iterators.

Variables and Data Types in C++

This chapter delves into variables and data types in C++. It explains that variables are named pieces of memory used to store data. The chapter covers various fundamental data types, including int, double, float, char, bool, void, and auto. It also discusses the concept of bits and bytes and how they are used to represent data in memory.

Number Systems in C++

This chapter explores number systems in C++, explaining how they are used to transform data between human-readable formats and computer-readable formats (ones and zeros). It covers the decimal system (base 10), the binary system (base 2), the octal system (base 8), and the hexadecimal system (base 16). The chapter demonstrates how to represent numbers in different number systems using C++ syntax.

Integers in C++

This chapter focuses on integers in C++. It explains that integers are represented by the int data type and are used to store whole numbers. The chapter covers different ways to initialize integer variables, including braced initialization, functional initialization, and assignment initialization. It also discusses the concept of integer modifiers, such as signed, unsigned, short, and long, which affect the size and range of values that can be stored in integer variables.

Fractional Numbers in C++

This chapter explores fractional numbers, also known as floating-point numbers, in C++. It explains that floating-point numbers are used to represent numbers with fractional parts and are represented by the float, double, and long double data types. The chapter discusses the concept of precision, which refers to the number of digits that can be accurately represented by a floating-point type. It also covers narrowing conversions, scientific notation, and special values like infinity and NaN.

Booleans in C++

This chapter focuses on booleans in C++. It explains that booleans are used to store two states: true and false. The chapter discusses the use of booleans in conditional statements and how they are represented in memory. It also covers the std::boolalpha manipulator, which forces std::cout to print boolean values as true and false instead of 1 and 0.

Characters and Text in C++

This chapter explores characters and text in C++. It explains the use of the char data type to represent individual characters and how characters are stored in memory using the ASCII encoding. The chapter demonstrates how to declare, initialize, and print character arrays. It also emphasizes the importance of null-terminated strings (C-strings) for proper output using std::cout.

The auto Keyword in C++

This chapter introduces the auto keyword in C++. It explains that auto allows the compiler to deduce the data type of a variable based on its initializer. The chapter demonstrates how auto can be used to simplify code and avoid explicitly typing long type names.

Assignments in C++

This chapter focuses on assignments in C++. It explains that after a variable is initialized, it can be assigned a new value using the assignment operator (=). The chapter demonstrates how assignments work with different data types, including integers, doubles, booleans, and characters. It also highlights the importance of being careful when using auto type deduction in assignments to avoid potential problems.

C++ Development Workflow

This chapter provides a comprehensive overview of the C++ development workflow, covering the steps involved in compiling and running a C++ program. It explains the roles of the preprocessor, compiler, and linker in transforming source code into an executable binary file. The chapter also discusses the concept of translation units and how they are used to manage code across multiple files.

Basic Operations in C++

This chapter covers basic arithmetic operations in C++, including addition, subtraction, multiplication, division, and the modulus operator. It explains how these operators work with integers and provides examples of their usage. The chapter also discusses the concept of operator precedence and associativity, which determine the order in which operations are performed in an expression.

Prefix and Postfix Operators in C++

This chapter explores prefix and postfix increment and decrement operators in C++. It explains the difference between prefix and postfix operators, highlighting how they affect the timing of the increment/decrement operation. The chapter provides examples of both prefix and postfix operators and demonstrates their usage in simple C++ programs.

Compound Assignment Operators in C++

This chapter introduces compound assignment operators in C++. It explains that compound assignment operators combine an arithmetic operation with an assignment in a single step. The chapter covers compound assignment operators for addition, subtraction, multiplication, division, and modulus. It demonstrates how these operators can simplify code and make it more concise.

Relational Operators in C++

This chapter focuses on relational operators in C++. It explains that relational operators are used to compare values and return a boolean result (true or false). The chapter covers the following relational operators: ==, !=, <, >, <=, and >=. It demonstrates how to use these operators in conditional statements and how they are evaluated in expressions.

Logical Operators in C++

This chapter explores logical operators in C++. It explains that logical operators work on boolean operands and combine them to produce a boolean result. The chapter covers the following logical operators: && (AND), || (OR), and ! (NOT). It provides examples of how to use these operators in conditional statements and how they are evaluated in expressions.

Output Formatting in C++

This chapter focuses on output formatting in C++. It explains how to use manipulators from the iostream and iomanip libraries to control the appearance of output printed to the console using std::cout. The chapter covers manipulators like std::endl, std::flush, std::setw, std::left, std::right, std::internal, std::setfill, std::boolalpha, std::showpos, std::dec, std::hex, std::oct, std::scientific, and std::fixed. It demonstrates how to use these manipulators to format output, control justification, set precision, and display numbers in different bases.

Numeric Limits in C++

This chapter introduces the limits library in C++. It explains how to use functions from this library to determine the minimum, maximum, and lowest values representable by different numeric types. The chapter provides examples of using functions like std::numeric_limits<T>::min(), std::numeric_limits<T>::max(), and std::numeric_limits<T>::lowest().

Math Functions in C++

This chapter explores math functions available in the cmath library in C++. It covers functions like std::floor(), std::ceil(), std::abs(), std::exp(), std::pow(), std::log(), std::log10(), std::sqrt(), and std::round(). The chapter provides examples of how to use these functions to perform various mathematical operations.

Weird Integral Types in C++

This chapter discusses integral types smaller than 4 bytes in size, such as char and short int. It explains that these types do not support arithmetic operations directly and that the compiler will implicitly convert them to int when performing such operations. The chapter emphasizes the importance of being aware of this implicit conversion behavior, as it can affect the size and behavior of variables in C++ programs.

Arrays in C++

This chapter introduces arrays in C++. It explains that arrays are used to store collections of elements of the same data type. The chapter covers how to declare, initialize, and access elements in arrays using indexing. It also discusses the concept of array bounds and the dangers of accessing data outside the bounds of an array. The chapter demonstrates how to write data to arrays, initialize arrays with data, and perform operations on array elements.

Size of an Array in C++

This chapter focuses on determining the size of an array at runtime. It introduces the std::size function, which was introduced in C++17, and explains how to use it to get the number of elements in an array. The chapter also discusses the use of the sizeof operator for getting the size of an array, but emphasizes that it includes the null terminator. It also highlights the benefits of using range-based for loops for iterating through arrays.

Arrays of Characters in C++

This chapter explores arrays of characters in C++. It explains that arrays of characters can be used to represent strings and that they are often referred to as C-strings. The chapter discusses the importance of null-terminated strings for proper output using std::cout and demonstrates how to declare, initialize, and print character arrays. It also introduces string literals, which provide a more convenient way to initialize character arrays with string data.

Array Bounds in C++

This chapter focuses on the concept of array bounds in C++. It explains that arrays have a fixed size and that accessing data outside the bounds of an array can lead to undefined behavior, including program crashes or memory corruption. The chapter provides examples of accessing data outside array bounds and emphasizes the importance of staying within the legal boundaries of an array.

Pointers in C++

This chapter introduces pointers in C++. It explains that pointers are special variables that store memory addresses of other variables. The chapter covers how to declare, initialize, and use pointers to access and modify data stored at the addresses they point to. It also discusses the concept of null pointers and the importance of initializing pointers before using them.

Pointer to Character Types in C++

This chapter focuses on pointers to character types in C++. It explains how to declare, initialize, and use pointers to characters. The chapter demonstrates how pointers to characters can be used to work with C-strings and how they can be initialized with string literals. It also highlights the importance of using const pointers to prevent accidental modification of string data.

C++ Program Memory Map

This chapter revisits the C++ program memory map, providing a more detailed explanation of how programs are loaded into memory and executed. It introduces the concepts of virtual memory, the memory management unit (MMU), and the different sections of the memory map, including the text section, data section, heap, and stack. The chapter also discusses the role of the MMU in transforming between the virtual memory map and the real memory layout in RAM.

Dynamic Memory Allocation in C++

This chapter explores dynamic memory allocation in C++. It explains how to use the new operator to allocate memory on the heap and how to release memory using the delete operator. The chapter emphasizes the importance of initializing pointers before using them and the dangers of using uninitialized or deleted pointers. It also discusses the concept of memory leaks and how to avoid them.

Dangling Pointers in C++

This chapter focuses on dangling pointers in C++. It explains that dangling pointers are pointers that point to invalid memory locations. The chapter covers three common causes of dangling pointers: uninitialized pointers, deleted pointers, and multiple pointers pointing to the same memory location. It also discusses solutions for avoiding dangling pointers, including initializing pointers with null pointers, resetting pointers to null pointers after deleting memory, and using a master pointer to control memory release.

When new Fails in C++

This chapter explores the possibility of the new operator failing to allocate memory on the heap. It explains that while new failures are rare in practice, it's important to handle them to prevent program crashes. The chapter covers two methods for handling new failures: using the exception mechanism with try and catch blocks and using the std::nothrow option with the new operator.

Null Pointer Safety in C++

This chapter focuses on null pointer safety in C++. It explains that null pointer safety involves taking measures to ensure that pointers are only used when they contain valid memory addresses. The chapter covers techniques for checking pointers against null pointers and emphasizes the importance of resetting pointers to null pointers after deleting memory. It also clarifies that it's safe to call delete on a null pointer.

Memory Leaks in C++

This chapter discusses memory leaks in C++. It explains that memory leaks occur when dynamically allocated memory is no longer accessible by the program, leading to wasted memory resources. The chapter covers common causes of memory leaks, including losing pointers to dynamically allocated memory, double allocation, and allocating memory within nested scopes. It emphasizes the importance of avoiding memory leaks and releasing memory using the delete operator when it's no longer needed.

Dynamically Allocated Arrays in C++

This chapter explores dynamically allocated arrays in C++. It explains how to use the new operator to allocate arrays on the heap and how to release memory using the delete[] operator. The chapter highlights the differences between dynamically allocated arrays and static arrays, emphasizing that dynamically allocated arrays do not work with std::size or range-based for loops.

References in C++

This chapter introduces references in C++. It explains that references are aliases for variables, allowing you to use a different name to refer to the same variable. The chapter covers how to declare, initialize, and use references to access and modify data. It also discusses the concept of const references, which prevent modification of the referenced variable.

Comparing Pointers and References in C++

This chapter compares pointers and references in C++. It highlights the key differences between them, including the use of the dereference operator (*) with pointers, the inability to reassign references, and the requirement to initialize references at declaration. The chapter also discusses the analogy of const references to const pointers.

The const Keyword with References in C++

This chapter explores the use of the const keyword with references in C++. It explains that const references create aliases that cannot be used to modify the referenced variable. The chapter demonstrates how to declare const references and how they differ from non-const references. It also discusses the use of const pointers to simulate the behavior of const references.

Manipulating Text Data in C++

This chapter introduces the concept of manipulating text data in C++. It explains that character arrays can be used to model C-strings, which are null-terminated strings. The chapter covers various facilities from the cstring library for manipulating C-strings, including strlen, strcmp, strcat, and strcpy. It also discusses the limitations of C-strings, such as the need to manage array bounds and null terminators.

Manipulating Characters in C++

This chapter focuses on manipulating individual characters in C++. It introduces various facilities from the cctype library for working with characters, including isalnum, isalpha, isspace, islower, isupper, isdigit, tolower, and toupper. The chapter demonstrates how to use these facilities to check character properties, convert characters between cases, and perform other character-related operations.

C-String Manipulation in C++

This chapter explores the cstring library in C++, which provides functions for manipulating C-strings. It covers functions like strcat, strcpy, and strlen, demonstrating how to concatenate, copy, and determine the length of C-strings. The chapter also discusses the potential safety issues associated with these functions, such as the need to ensure that destination arrays are large enough to accommodate the concatenated or copied data.

The std::string Type in C++

This chapter introduces the std::string type in C++. It explains that std::string is a high-level type that provides a more convenient and safer way to work with string data compared to character arrays. The chapter covers how to declare, initialize, and use std::string objects, highlighting its automatic memory management and support for various string operations.

Declaring and Using std::string in C++

This chapter provides a detailed explanation of how to declare, initialize, and use std::string objects in C++. It covers various initialization methods, including initializing with string literals, other strings, and multiple copies of a single character. The chapter also demonstrates how to print std::string objects using std::cout and how std::string objects can automatically grow to accommodate additional characters.

The One Definition Rule in C++

This chapter explains the One Definition Rule (ODR) in C++. It states that definitions of variables, functions, and static members cannot appear more than once in a program. The chapter discusses exceptions to the ODR, particularly for classes, where definitions can appear in multiple translation units. It provides examples of violating the ODR and demonstrates how to avoid compiler errors related to multiple definitions.

Functions in C++

This chapter introduces functions in C++. It explains that functions are reusable blocks of code that can take input, perform operations, and return output. The chapter covers the syntax for declaring and defining functions, including specifying the return type, function name, parameters, and function body. It also discusses the concept of function signatures, which uniquely identify functions based on their name and parameters. The chapter demonstrates how to call functions and pass arguments to them.

Function Declarations and Definitions in C++

This chapter focuses on function declarations and definitions in C++. It explains that functions can be split into two parts: a declaration (prototype) and a definition. The declaration provides a summary of the function's return type, name, and parameters, while the definition includes the function body with the actual implementation. The chapter demonstrates how to separate function declarations and definitions and emphasizes the importance of placing declarations before function calls.

Passing Parameters to Functions by Value in C++

This chapter explains the concept of passing parameters to functions by value. It demonstrates that when parameters are passed by value, copies of the arguments are created and used within the function body. The chapter highlights that modifications made to parameters passed by value do not affect the original arguments.

Passing Parameters to Functions by Pointer in C++

This chapter explores passing parameters to functions by pointer. It explains that passing by pointer allows you to modify the original arguments by dereferencing the pointer within the function body. The chapter demonstrates how to declare functions that take pointers as parameters and how to pass the addresses of variables as arguments.

Passing Parameters to Functions by Reference in C++

This chapter introduces passing parameters to functions by reference. It explains that passing by reference creates aliases for the original arguments, allowing you to modify them directly within the function body. The chapter demonstrates how to declare functions that take references as parameters and how to pass variables as arguments. It highlights the benefits of passing by reference, such as avoiding copies and simplifying code.

Returning from Functions in C++

This chapter focuses on returning data from functions in C++. It explains that functions can return values using the return keyword. The chapter demonstrates how to return values from functions and how the returned values are used in the calling context. It also discusses the concept of return by value and how the compiler may optimize returns by value to return by reference in certain cases.

Function Overloading in C++

This chapter introduces function overloading in C++. It explains that function overloading allows you to define multiple functions with the same name but different parameters. The chapter covers the rules for creating valid function overloads, emphasizing that the return type is not considered when determining function uniqueness. It demonstrates how the compiler selects the appropriate overload based on the arguments passed during function calls.

Overloading Functions with Different Parameters in C++

This chapter provides a detailed explanation of how to overload functions based on different parameters. It covers techniques for creating overloads by changing the types of parameters, the order of parameters, and the number of parameters. The chapter demonstrates how the compiler resolves function calls based on the types and order of arguments passed.

Lambda Functions in C++

This chapter introduces lambda functions in C++. It explains that lambda functions are anonymous functions, meaning they don't have a name. The chapter covers the syntax for declaring and defining lambda functions, including the capture list, parameter list, return type, and function body. It demonstrates how to give lambda functions names and how to call them directly or through handles.

Declaring and Using Lambda Functions in C++

This chapter provides a detailed explanation of how to declare and use lambda functions in C++. It covers the syntax for defining lambda functions, including the capture list, parameter list, return type, and function body. The chapter demonstrates how to give lambda functions names and how to call them directly or through handles. It also explains how to pass parameters to lambda functions and how to return values from them.

Summarize any YouTube video in seconds

Get summaries like this one for any video, in your language, with the free Summ app.

Download on the App Store
Get it on Google Play

Transcript

Full transcript of “C++ Programming Course - Beginner to Advanced”. Click a timestamp to open the video at that moment. Need another video? Use the YouTube transcript generator.

0:00 this complete c plus plus course will take you from being an absolute beginner to using advanced c plus plus features danielle gaguaya teaches this course he is an experienced software developer and has created many popular courses hello guys and welcome to this modern c plus plus 20 course this is a course that is going to take you from the absolute beginning where you know nothing about c plus plus and you're going to go all the way to a point where you can use some advanced features in the c plus plus programming language that includes things like object-oriented programming with inheritance and polymorphism with the c plus plus programming language now i'm not going to spend a lot of time convincing you on why you should use c

0:45 plus plus but c plus plus is a very powerful programming language you can use to do all kinds of crazy things you can use it to do systems programming you can build games with it and it is used in a wide range of areas so you can do a lot with c plus plus now who is this course for this course is built for complete beginners if you already have some experience with c plus plus you will still find some good things you can learn from the course but i am going to go from the absolute beginning showing you every little thing showing you the tools showing you the compilers and the editor we're going to be using here so we're going to spend a lot of time making sure you understand the fundamentals by the time you are done with this course you will understand the

1:30 bare fundamentals about c plus we will spend a lot of time exploring the procedure programming side of c plus plus so you're going to be writing programs that run from top to bottom and we're going to spend a lot of time in the editor writing code making sure you really understand what is going on here towards the end we're going to learn about object oriented programming and we're going to touch on classes inheritance and polymorphism and these are the tools you're going to be using a lot in your career as a c plus plus developer another great feature of this course is that we spend a lot of time making sure you understand the tools so if you don't know what a compiler is if you don't know what an ide is we're going to make sure you understand these things and we're going to spend a lot of time using these things and by the time

2:16 you're done with the course you're going to be very comfortable using the tools the editor of choice for the course is going to be visual studio code so that's an editor that is going to allow us to type in the code and give us some things like a syntax highlighting but we're going to be connecting our editor to a background compiler which is going to make sure our code is transformed to run on our computer but don't worry about all that craziness right now we're going to go in detail about these things for now i just want you to have a bird's eye view on what you can expect from the course here now i hope you know what to expect from the course but i also expect you to be ready to take the course and the requirements are really not that bad

3:02 the only requirement is that you have time set aside to really practice what you learn from the course here and you need to have a strong drive and willingness to learn now if you want to follow along i am going to share a link to the github repository for the code i use in the course so you can check that out and really follow along if you want if you want some support we have a discord server dedicated for our students so you can join and be part of the community if you have a question you can ask but another thing i would encourage you to do is to also help others so if you see somebody asking a question try to help them you're going to learn a lot that way okay now that you know a bit about the course let's talk about myself here my name is daniel cacoya i am a software engineer i have

3:48 been writing code since 2011 or something and i am a professional c plus plus developer i do a lot of freelance work i work for a few companies i do all kinds of crazy things i also like to teach others so i have a few courses on udemy if you are interested in cute you can check these things out i also have a trending c plus plus course that you can check out but don't feel the need to go and check this ziplesque course out because a lot is covered in this youtube course here so that's really all about me okay now that you have an idea about the course we're going to head over in the next lecture and learn about the tools we're going to be using throughout the course here go ahead and finish up here and meet me there welcome to this new chapter where we're

4:34 going to be exploring the c plus plus development tools you need to start writing your own c plus plus applications and you really need two kinds of tools the first one is going to be an editor or an ide through which you're going to be writing your c plus plus code we are going to be using visual studio code as an editor in this course because it is very easy to install it is cross-platform it is going to run well on windows mac and linux and it supports a host of tools that are going to make your job easier as a surplus plus developer but that's not to say you can't use your favorite ide if you can but visual studio code is going to be our main editor in this course so i would recommend installing it to be

5:20 able to follow along with what we do here now after we have an ide or an editor in place we will need a compiler and the compiler is a piece of software that takes the code we write in the editor and compiles that into code that can directly run on the hardware or binary executable format so this is what we're going to be doing here we're going to be typing our code in an editor like visual studio code we're going to be kicking off a process to compile our program and this is going to turn our program into a format that can run it directly on the hardware so for example if you are on a windows machine you're going to generate a binary executable that can directly run on windows if you

6:05 are on linux we will generate a binary that can run on linux and the same concepts can really extend on mac or any other kind of operating system you might be working on with the course here so we need two tools we need an ide or an editor and a compiler and the tools you install are going to be depending on the operating system you are using to watch the course if you are on windows you're going to install a set of tools that are specific to windows if you are on linux you're going to install a set of tools for linux if you are on a mac you're going to install a set of tools specific to the apple operating system for desktop now on windows in terms of ides or integrated development environment it

6:52 is possible to use a host of ides for example you can use code lite it is an ide you can use you can use microsoft visual studio but in this course we're going to be using visual studio code because it is easy to install it has a set of features that are really good it is popular it has a great community around it i think you're going to have a great time as a beginner to start writing your c plus plus programs using visual studio code that's not to say that you can't use another ide you can if you want but i am going to be using visual studio code in this course here now on linux we are also going to be using visual studio code as our editor in the course but there are other ides you can use for example you can use cute

7:39 creator if you want you can use codelight you can use a host of other ides on linux but again visual studio code is going to be our thing in the course here and i would recommend installing it on your linux box if you are watching this course on the linux machine so for osx we are also going to be using visual studio code as our editor as i said it is cross platforms it runs where regardless of the operating system you might be using to watch the course but if you want you can use the apple ide which is xcode or even code lite all these are going to work if you want but again i would recommend going with visual studio code.plus to start out so that we have a common ground and you don't get confused very easily

8:24 especially if you are a beginner now after we have an ide rolling we will need a compiler and as we say the compiler is a tool that is going to transform your c plus plus code into a format that can run directly on the hardware so the compiler you use again is going to depend on the operating system where you are watching the course i am going to show you a bunch of compilers you can use but gcc is going to be our common base so on windows i will be using what we call mingw don't worry if you don't what it is i am going to show you in a minute when we install it but this is a project that brings the gcc compiler on windows so that we can use it easily and i am going to show you how to install it but i am also going to show you how to

9:09 install the compiler from microsoft and the clang llvm compiler these are all available to you on windows and it is really easy to install them these days and i will be using them all if you are on windows i would recommend installing them all so that you really have a chance to try your c plus plus code on the different compilers and that's a really good thing to do if you test your c plus plus code against multiple compilers you will be increasing your chances for your code to really be portable and work on multiple compilers and operating systems and that cannot be a bad thing so i would recommend installing all these compilers if you are on windows i am also going to show you how to install two compilers on linux i am going to show you gcc we're

9:56 going to install the shiny new feature in gcc we're going to install clang lvm on linux and we will be able to use all these compilers again if you are on linux i would recommend installing all these compilers so that you have a chance to try your code against multiple compilers and that's going to make your code much portable and easier to use on multiple compilers and platforms on the mac i am going to show you how to install gcc and i am going to show you how to install clangle lvm but if you want you can also install xcode and the compiler that comes with that for c plus but development all these are options to you but again in this course we are mostly going to be using the gcc compiler so i would recommend getting a hold of this

10:43 if you don't want to install other compilers if you only have to install one compiler please install gcc that's going to be our main compiler in the course here okay so these are the tools we need we are going to head over in the next lecture and show you how to install the visual studio code editor on windows and really get started with that go ahead and finish up here and meet me in the next lecture this video i am going to show you how to install a c plus plus compiler on your windows operating system so we're going to be looking at three kinds of compilers we're going to look at the mingw compiler which gives us access to a gcc like compiler on windows we're going to look at clan llvm which is another compiler we're going to look at the compiler from microsoft

11:30 now before we talk about any compiler i would like you to come to google or your favorite search engine and say c plus plus compiler support okay so we're going to choose this little guy here and this is really going to give us a berg's eye view on which feature is supported by which c plus plus compiler for example if we are interested in c plus plus 20 which is the lattice standard that we have in simplest plus at the time of recording this video i am recording of this in august 2021 but if we go here we're going to see c plus plus 20 core features and we're going to see that we have a list of what each compiler supports we have gcc we have clan we have msvc we have the clan version from the apple company

12:18 and if we scroll down we can really see the features that are supported by each compiler again gcc is going to be our choice in this course this is going to be our main compiler but nothing really stops you from using the clan compiler or the msvc compiler and if you happen to see that your compiler of choice doesn't support what you need for example you can see that at the current time lambdas in an evaluated context are not supported in clan you can see that it is ready here but this is a feature you can use both in gcc and the msvc compiler from microsoft so keep an eye out on this page here to know which kind of things you can use in your compiler if you try something out

13:03 and you see that it doesn't work this is a good place to come and figure out if your compiler supports the feature that you are using in this video i am going to show you how to install the three most common compilers and those are gcc clang msvc if you want you can come in your search engine and type gcc to see what this is it is a good thing to do to learn about your tools here you can see that it is a compiler that is mostly used on the lenox platform but we can also use it on windows the latest release that we're going to be installing is eleven two zero i think it was released six days ago so it is really fresh and we're going to be taking advantage of this another thing i should say here is that you should install the latest tools you can get your hands upon this is the

13:50 version we're going to be mostly using in this course but if you are watching this in the future you're going to have a newer version i would recommend installing the latest version or the newest version you can get your hands upon so the first we're going to do is install a gcc compiler on windows i am going to show you a way we can get both gcc and clang in one go and to get access to that please go in your search engine and type windlabs and this is going to bring us to this project here if you want you can click upon this and this is a cool project by a guy who is providing worlds for these compilers that we can use on windows so if you want you can just go down here and look at the lettuce releases again i

14:35 recommend using the lettuce you can get your hands upon in this case the lettuce happens to be 1120 but in the future this is going to change you're going to find a version for 12 or 13 so please grab the newest version you can get your hands up on now i want you to install the version that says that it has llvm and clang so if you are on a 32-bit version on windows i would recommend getting this 7-zip archive on this zip archive here if you are on 64 i would recommend getting a hold of this or this little thing here it doesn't really matter but make sure you get the latest version you can get your hands upon and you can see that this conveniently says latest here so i am going to download the 64-bit version

15:22 on windows i am going to grab the zip archive here and let's click upon this this should kick off my download and this is going to download on my system i can download this if i want and you're going to see that it is going to start downloading here and i am going to wait for this to finish again this is going to give us both the gcc compiler and the clan compiler and this is really like shooting two birds with one stone so this is going to be really good i already have this downloaded so i am just going to head over to the location where i have this downloaded i think i can just go in my drive here so let's crack this open and go in my downloads folder and if i go in my compressed folder i am

16:08 going to find winlabs llvm and mingw this is what you really want but if you don't want the clan compiler you can grab the one that doesn't say llvm here because we really want both of these compilers we are going to grab the one that has both the gcc compiler and the clan compiler if we crack this open let's open this together so that you can see what is happening we are going to have this little folder here if we go in we're going to find a bin folder if we go in and crack that open we're going to have a folder that says clang you see we have a clang compiler we have our clan plus plus compiler for c plus plus and if we go down we're going to find our g plus plus compiler and the gcc compiler this is what we want so what we are going to do

16:55 is extract this somewhere on our system i put this on my c drive so if you go here you're going to find mingw64 so all you really have to do is go where you downloaded your compiler and say extract we're going to right click on this and say extract to a location and you're going to specify where you want this to go and this is going to be extracted or even if you want you can extract here this is something i like to do this is going to show up in the current folder and you can grab this and paste that in a location where you want this in my case i put this in my c drive as i said here so this is going to be my compiler now once you have these compilers installed again we have the clan compiler we have the gcc compiler if we

17:42 go down we're going to find the g plus plus we even have gdb which is a debugger we can use to debug c plus plus applications but we will talk about this later once you have this i would recommend putting this in your environment variables on windows the way you do this you grab this path well we have our compilers here and we're going to copy this this is something i recommend and on windows 10 you can go on the start menu and type env and this is going to give us a window in which we can edit our environment variables we're going to click on this little thing this is going to open up on our system we're going to wait for this to open up and we're going to have a window that says system properties we're going to click on environment variables here and we can put this in our user

18:30 environment variables or on our system environment variables since i am the only one using this system i like to put this in my path for my system variables so i am going to click on path and click edit here and i am going to add a path to my gcc and cloud installation here you can see that right here if you don't have this end you can click on new you're going to have a window here and you can paste this right in and you can click ok but i'm not going to do that because i already have this in here so what i am going to do is just delete this let's see if i can delete i can delete this little guy and i have my path in here so if you don't have this in please make sure you have this in your environment variables so we're

19:15 going to cancel out of this but if this is the first time you do this you should click ok and one way to test that your environment variables are working or even if your compilers are working is to crack up a command line terminal so we're going to say cmd on the start menu here and all you need to do is say g plus plus just like this dash dash version if you do this you're going to see information about your c plus plus compiler and this is coming from the installation we just did and for clan you can say clan plus plus version and this is going to tell you the information about your clan compiler installation let's wait for this to come up i don't know why it's slow but you can see that we have a

20:01 clank compiler the lattice version is 1201 for the gcc compiler the latest version is 1120 and these are the compilers we can use to write c plus plus 20 applications okay so by now we have a gcc compiler through the main gw project we have a client llcm compiler on our system we are also going to see how to get a hold of the compiler from microsoft and to get hold of this you need to install microsoft visual studio to install microsoft visual studio all you have to do is come to your favorite search engine and say microsoft visual studio we can look at the 2019 version which is the latest i think and we're going to click on the download link here we have as the first link and we're

20:48 going to see ways we can download this little guy now microsoft visual studio has a community version you can download for free but we also have a professional and enterprise versions that we're not going to care about in this course here we are just going to download the community version and that's going to be enough for our purposes here so if you click on free download here this is going to download and install the visual studio compiler you can click on this little guy and it is going to download an installer you're going to crack this open on your system and it is going to install the visual studio installer so once you have it installed you can come to the start menu here and say visual studio installer i think if you say visual studio you're going to

21:33 have this pop-up somewhere on your system we're going to click on this and if you crack the installer open you're going to see a window like this which is really going to give you a chance to install the tools you want to use with the microsoft visual studio ide and in this case we are interested in desktop development with c plus plus so we're going to click this little guy here we're going to take it open and once you do this you going to click download and install and this is going to install the visual studio compiler with the underlying compiler you see that this is going to give us access to the msvc compiler and all kinds of crazy things we really needed to write c plus plus applications on windows using the compiler from microsoft now i have to say this is going to take some time to

22:20 install so if you see that this takes up 20 minutes of your time don't worry this is really normal because this id and the compiler behind it and really large they're not like the gcc or the clan llvm compilers that we just installed okay so once you have this ticked or checked you're going to click on download or install whatever this button is saying here this is going to install both the microsoft visual studio ide and the compiler from microsoft that you can use directly to write c plus plus applications so once we have this open i am going to suppose that you have this installed already i am going to close out of this because i don't want to do this and you're going to have visual studio installed on your system once you have this installed you're going to come to

23:06 the start menu and say developer and this is going to bring up two things one is going to be the developer powershell for visual studio 2019 and the other is going to be a command prompt it doesn't really matter what you choose i am going to click on the command prompt here and once you do this this is going to give you a terminal or a window through which the environment variables are already in to start using the compiler from microsoft and if we come here and type cl.exe we're going to see that we're going to see the information here if this gives you an error or something you're going to know that you didn't really install this properly so please go back and make sure you have this installed if you have a problem you can ask me i can do the best i can to help you out but by this

23:52 moment we have three compilers on windows that we can use for c plus plus development we have the mingw or the gcc compiler in our hands we have the klanga lvm compiler and we have the compiler from microsoft and now we can install an ide or an editor and that's going to be visual studio code and we can connect that to these compilers so that we can start writing our own z plus bus 20 applications we are going to head over in the next lecture and install the visual studio code editor go ahead and finish up here and meet me there in this lecture i am going to show you how to install the visual studio code editor on windows so if you are watching this course on windows this video here is going to be a must watch

24:39 we are going to head over to our search engine and type visual studio code this is going to give you a link where we can download this cool editor if you want you can learn all you can about it it is a source code editor made by microsoft it supports multiple languages but we're going to be using that specifically for c plus plus in the course here here i am at the page for the editor and you can read all you want about it but we are interested in downloading this for windows if you want you can click on this download button here but i am just going to scroll down and have download links for windows if i want i can click on user installer system installer you can click on what you want if you are on a 32-bit system you're going to download a 32-bit

25:25 version i am just going to click on 64-bit here because i am on a 64-bit operating system again in this video we are doing this for windows so this is going to be our area of interest here i am going to click on this download link and i am going to wait for things to kick off and i will have a window to start downloading visual studio code setup here i can save this file and it is going to start downloading once it is downloaded i am going to double click and really click my way through this until i have a visual studio code installed on my computer here okay the download is good i can crack this open let's click on this and you're going to see that it is saying that it has detected that visual

26:11 studio code is already running on my system because i have it installed but if you don't have it installed you're going to click your way through and install this on windows and after you have it you can start it okay once you start visual studio code you're going to have a window like this if you run it for the first time you are probably going to see a windows with documentation and whatever let's look at the welcome screen you're going to probably see you're going to probably see something like this but i am not sure but the most important thing is that you're going to have a window like this with visual studio code the first thing we want to do for c plus plus development is going to scroll down and click on this little thing that says extensions i am going to click on this and i am going to go in my search box

26:57 here and type c and c plus i can even type c plus plus it doesn't really matter and this is an area where we can install extensions to make visual studio code do all kinds of crazy things in this case we are interested in making it support c and c plus plus so we are going to click on this extension that says microsoft here cnc plus plus i am going to click on this and if you don't have it installed you can click on the install button and it is going to install this little thing and make your computer ready to use visual studio code for c plus plus so make sure you install this and at the end it is going to say disable or uninstall because it will be already installed and enabled on your

27:43 computer and this is really the end of our installation video for visual studio code we are going to head over in the next video and show you how you can make a visual studio code use the compilers that we installed in the previous video so go ahead and finish up here and meet me in the next lecture in this video we're going to see how to connect our visual studio code editor to a compiler so that we can compile our projects easily through the visual studio code editor we already have the ide installed from the last two previous lectures when we have a compiler installed in the last lecture we installed the gcc compiler through the mingw project we installed the clangela vm compiler we even installed the compiler from microsoft now we're going

28:30 to connect the ide to the compiler to make it really easy to compile c plus plus applications using these tools here what i am going to do is really set up a template project we're going to be reusing throughout this course here so i am going to go on a folder in my system and i am going to right click on the folder and say open with visual studio code let's do this this is going to open this folder in visual studio code and i am going to trust this folder here be careful what you trust because some things are going to do some malicious things on your computer make sure you trust the folders that you open up so i am going to trust myself because i am the creator of this folder here and this

29:15 is going to open visual studio code now in our install video we installed the c plus plus extension for visual studio code again if you don't have this installed please make sure you go back and install and make sure this is saying that this is enabled and now we want to use this to write c plus plus applications here we're going to write a simple toy c plus plus application to just test that our compilers support c plus plus 20 and then we're going to use this as a starting point or as a template project so i want you to click on this little plus icon here and we're going to create a file called main.cpp and once you do that you will be able to type c plus plus code in this year so we

30:01 are just starting out here i would recommend to type this exactly as i do here so we're going to say include and say opening angle bracket and say io stream and we're going to go down here and say and main and we're going to go inside these curly braces and say auto result and you are going to exactly type what i tap here don't worry we're going to have a chance to learn about all these things here so i am going to put a pair of parentheses and i am going to say 10. and i am going to put a weird operator here this is called the spaceship operator it is just something we can use to test that our compiler supports it plus plus 20 and

30:46 we're going to put a 20 here and then we're going to try and see if this is greater than zero and we're going to print this out we're going to say stdc out again don't worry if you don't know what this is this is just a way for us to test and see if our compiler is going to be able to use c plus plus 20. we're going to say result here and this is going to be our program now we want to make sure we compile this program so to bring in your compilers in visual studio code all you have to do is come to the terminal menu here so please come here and we're going to have an option to configure tasks i want you to click on this and once you do this you're going to see that visual studio code is going to find the compilers that we just installed you

31:33 see that it has found the gcc compiler we installed in mingw you see that it has found the clan compiler i know about the g plus plus compiler because you can see the path here you can see c major w ben g plus plus dot exe this is where we installed our g plus plus compiler and i know about the clank compiler because that's what's being found here for example on this entry here you see it says cmajw bin clan plus plus so we wanted to configure these two compilers here and later visual studio could use them to build our c plus plus 20 projects now what we're going to do is click on the g plus plus compiler first and when we do that this is going to create a tasks that json file in our

32:22 project and you see that it has created a folder called dot vs code if i click on my main cpp file here and do reveal in explorer this is going to open up on my system and you see that this has created a dot vs code folder and if we go and we're going to find this tasks.json file this is going to be our configuration to configure which compilers that visual studio code is using to compile our main.cpp file here so if we go in it's going to really have everything ready for us so you're going to see that it's going to be using our g plus plus compiler this is the path to it and in our args options here we have the options that we pass to the compiler to

33:08 compile our program here now i want to change this to say which kind of compiler we are using so we're going to change the level here to say world width g plus plus and say the version i think that's going to be more descriptive here so we're going to save world with g plus plus or gcc and we're going to say 11.2.0 because that's our version here and the rest is really going to be enough so let's try and see if we can compile our program here and see the thing here printing out but the other thing we need to do because this program is using c plus plus 20 we need to configure our compiler to use c plus plus 20. and one way to do that in

33:54 gcc and you can really search these things for example if we come to our search engine here and say configure gcc to use c plus plus 20 or even gcc and say c plus plus 20. you can search these things and find information and it is a really good way to test your things here so let's see if we can find a link to help out we have a stack overflow link here so we can crack this open and if we go and we're going to find a batch of things for example we can say std c plus plus 20 here as an option to our compiler and this is going to bring c plus plus 20 support in our gcc compiler so i am going to copy this and i am going to come back in my visual studio code editor

34:40 and i am going to pass a flag to boiled in c plus 20 mode and it is something i just got from stack overflow here and we are going to pass this to our compiler and put a comma to make this a valid configuration file and i am going to close this now once we have this open and we want to build this we need to bring a terminal window so we we're going to bring the terminal window so that we can see things happening and we do that by coming to terminal and saying the new terminal and we will come back to terminal again and say that we want to run a task in this case we're going to be running our world with gcc 1120 again if you are using a newer version that's what you should use and if we click on this thing please make sure you have the main cpp

35:27 file selected before you do this so i have this selected and i'm going to go to run task and i am going to click on this little thing you're going to see that this is going to kick off the process to build our program and we're going to wait for this to finish and you're going to see that it is using c plus plus 20 here we're going to see that the world finished successfully and we have a main.exe file created here so if we go in our terminal in visual studio code and click enter and type clear and hit enter this is going to clear the screen this is something you can do to clear things out we can run this main.exe binary directly here so we're going to run exe here and if you run it it's going to say zero and

36:14 this is an indication that we have our visual studio code editor connected up to our gcc compiler and we can use that to compile c plus plus applications and this is really the configuration with it now you may ask how do i know this how do i did i know the steps to follow to get this to work well if you come to extension tab here and before we even do that i want to bring to your attention that we have a bunch of tabs here in visual studio code we have a tab that says file i think the one here saying explorer we have a one we can use for version control if you use something like git or whatever you can use this but in this course we're mostly going to be using the explorer tab here and the extensions tab to install things and at

37:01 a later time i will show you how to use the debug tab here or run a debug tab but in most cases we're going to be using the explorer tab or the extensions tab here if you want you can click on this to close this so that you have some more space you can click again to bring this back these are some things you can do in visual studio code but i am going to show you how to configure your compilers where i got the information so click on extensions here and we're going to find our cnc plus plus extension if we scroll down we're going to find tutorials on how to set up this on different compilers for example you can crack this open to see how to set up a visual studio code to use your compiler from microsoft if we come back we can see a link to see

37:46 how to use this with mingw on windows let's click on this and let's see what else we have we can come back to here and we can see how to use this with gcc on linux or clango on a mac you can really choose whatever is relevant for your operating system but in this case here we are just using the windows operating system so we're going to see how to use this with the mingw compiler that we just installed now we can use the mingw compiler and i would recommend reading up on this entire thing to have an idea on what is happening we already have our g plus plus compiler so this is this command is going to work again if we come back to terminal here and run g plus plus version i think we can see that we run

38:32 these commands here to see these things working so we have this step here and if you wonder what gdb is it is just a debugger you can use to debug your programs and again if we come to our terminal here and say gdb version we're going to have this available from our mingw installation you can see that we have this here so this is working just fine you can really follow this and configure your visual studio code installation but i am just showing you how to do this pretty fast you can see that this is what we set up in our configuration file which is our tasks dot json file now one thing you can do is modify the task.json file to build every single file in your project and this is something that is going to

39:18 make things easier what i'm going to do is go back to our visual studio code instance and find our project we're going to crack open our tasks that json file which is living in our dot vs code folder and i am going to take out the craziness i have in my arguments here i am going to select everything i am going to delete that and i am going to put in a configuration that i am using for my projects here to make this super easy what this is doing it is telling the compiler to build in c plus plus 20 mode it is going to tell visual studio it is going to tell the compiler to build every single cpp file in our project so if we have multiple files they are going to be built together and we're going to specify the

40:04 name for our output file for example if we don't want our binary executable to be named mainly.exe we can give it a name and i am going to be naming mine rooster.exe in the course here i would recommend doing the same so that we can really have the same habits as we go through the course here but of course you are free to use whatever you want in your c plus plus programs here so once you have this you can click save here and this is going to save our json file here i can close this and i am going to bring my terminal by going to view and the terminal here this is going to bring back my terminal that i had before and i am going to run the clear command and hit enter and i am going to do dir to show the

40:51 contents of my folder on windows here i wanted to remove the main.exe file from the terminal here so what i am going to do is say rm and i am going to say the name of the file i want to remove i am going to say main dot exe and if i hit enter notice what is going to happen the file is going to go away i don't see it anymore here i want to build again using my new configurations in my tasks the json file i am going to run the task to build with our gcc compiler this is going to build again and you see that it is using the configurations that i passed you see that it is building every single cpp file in the directory here and it is going to generate a

41:38 program called rooster.exe and we if we look here we're going to find it we can hit enter in the terminal and we can type clear to clear things out and if we do the ir again we're going to see that we have rooster.exe and we can run it by doing rooster.exe here and this is going to do what we want this is really all you need to do to connect visual studio code to your gcc compiler now we're going to connect visual studio code to our clan compiler that we have installed we really want to be able to use it with our project here and we're going to go through the seven steps again so we're going to go to terminal and say configure tasks and we're going to choose something that says the clanger compiler and we're going to find clang plus plus so let's

42:26 hunt for that i have something that says that here we have cloneplusplus.exe i am going to click on that and if i do this this is going to add an entry in my tasks.json file so watch out for this i am going to click on this and let's crack this test that json file open and you're going to see that this is going to also set up another configuration to world using my clang plus plus compiler and again i can edit this out a little bit to say what we want let's look at the version of cloud we have installed to say that out this is going to be 12 0 1 so we're going to say world with clank plus plus

43:11 12 0 1 let's say that here in our level 12.0.1 we can say that right here and you see that it is really doing the same thing we did with our gcc compiler so what i can really do is still everything i did in my gcc compiler i can copy this and i am going to take out the arguments i have in my args here and i use what i have in my gcc compiler you can see that you can use the client compiler and the gcc compiler in the same way and this is something really cool so now we have the option to use two compilers and this is really cool so we're going to close the json file and it's going to be saved automatically and we're going to bring up our terminal window again

43:58 and let's bring this up a little bit and we're going to do dir on windows and we're going to remove the binary again we're going to remove roster.exe and again what you can do you can start typing the name of the file you want to remove and hit tab if you do that the terminal is going to autocomplete this for you and this is really cool so if i do this the file is going to go away you see that it is going right here and i can clear and what i am going to do is world with the clan compiler can do that by coming to terminal i am going to say that i want to run a task and i am going to be given an option i can either build with gcc so if i choose gcc here it's going to be used but i can also use clan let's use clang here so i'm going to click on

44:44 this and you're going to see that visual studio code is going to kick off the world process this is going to build my binary executable and notice that it is using c plus plus 20 again the build is going to finish successfully and i will have a binary here and this is going to be all i need to do so if i hit enter and run my binary by tapping the name and hitting tab this is going to auto-complete if i run it it's going to say zero and this is what we expect here if you have some kind of error please try and fix it if you have a problem you can ask me and i will do the best i can to help you out okay now we have our two compilers working we need to configure the compiler from microsoft now the compiler from microsoft is a little bit weird

45:31 again you can read up on this by coming to your extension documentation and going to using the compiler from microsoft with visual studio code on windows you can read up on all this if you want but i am just going to show you a quick way to get this running so the compiler from microsoft is special in that you have to specify the path to it for example if we open a regular terminal window and say cl.exe to call the compiler we're going to see that the terminal is going to say that the cl.exe compiler is not recognized and the reason is we don't have the proper environment variable settings for the operating system to find this compiler when we call it right here we are able to use g plus plus and clan because we

46:16 put the environment variables in place if you remember when we installed them we did something like this we came to the start menu and did env we came to environment variables here and we put the path to our compilers in our environment variables here you can see them right here so we don't have the same thing for the compiler from microsoft and that's for a reason because we may have multiple compilers installed from microsoft then if you have multiple compilers it would be really cumbersome to choose which compiler you want the guys at microsoft opted for the option for you the developer to specify which compiler you want to run by coming to the start menu here and typing developer and choose which powershell for the

47:02 compiler you want to use for example if we want to use the visual studio 2019 compiler we can click on this and then we will have a terminal that can run the c plus plus compiler from microsoft for example if we wait for this to be ready and say cl.exe we're going to see that we're going to have a message saying that this is our compiler we can use it however we want so what we're going to do is set up a terminal like this and use this terminal to start visual studio code and the visual studio code is going to start in the mode where it can find the compiler from microsoft i know this is confusing but please bear with me this is what we need to do to get this to work if we start visual studio code in a mode where it knows about the environment variables

47:48 for the compiler from microsoft we will have the ability to say cl.exe and we will be able to use that right here but you see that it is not recognized now but we can use the g plus plus compiler if we do this version we're going to see that it's available we can use it we can use clan plus plus and if we do version as well we're going to see that we can use this little guy here we also want the ability to use the compiler from microsoft but to have access to that we will have to close the visual studio code instance we have here and we're going to come back to our project let's see if i can find it here so we're going to go to the location where we have our project and we're going to change to the location of the project here so i can grab the location

48:34 from my visual studio code project that i just set up i am going to come back to my powershell window that knows about the path to the c plus plus compiler from microsoft and i am going to change it to the location of my project here so i am going to say cd and paste in the path i just copied and if i hit enter this is going to change to my location and i really recommend using powershell if you have access to this because it is a little more convenient to use it supports more commands that you can use in the command prompt but again that's going to be your choice now i am in the location for my project if i do ls or dir you can see that i can see my main cpp file can see the binary we generated earlier but this is not problem so what

49:22 i can do here is say code and i say a dot and this is going to start visual studio code in the current folder of our project year so if you hit enter we're going to wait for visual studio code to come up it is going to come up with the project we had in that folder and the special thing about starting visual studio code this way is that it's going to know about the compiler from microsoft if we come back to our terminal here and clear and say cl.exe you're going to see that now it knows about the compiler from microsoft and we can use it to do things so let's set this up again if you want you can read up on how to do this on the documentation from visual studio code itself but again i am going to show

50:07 you how to do this you can see that it is really the same things they are doing here so let's come back to visual studio code and we're going to go to terminal and we want to configure a task now you see that we have the compiler from microsoft available you can see that we can use that right here so what i am going to do is click on cl.exe world active file and this is going to add a new entry in our configuration file and it is going to open up if we go here we are going to find that we have a command to build using the compiler from microsoft so let's change the level here and i say world with msvc i think this is going to be more descriptive and this is really going to build your thing now i am going

50:52 to change this up so that it works everything in the current folder and again i am going to remove everything here and put in a configuration that i have ready on my system here this is what i use for all my projects again this is just calling the compiler and giving it options to do things we just need to specify that we want to use the lattice standard of the c plus plus standard and it is going to specify the input files we're going to be building everything in the current folder this is what we are saying here and the output file is going to be called rooster.exe if we save this by saying ctrl s or command s and close our tasks dot json file we can bring up our terminal window by going to

51:38 view and saying the terminal here and we can go down and clear we can say clear and hit enter and if we do rm and say rooster and hit tab this is going to remove the binary we generated with the clang llvm compiler earlier now we want to build with the compiler from microsoft so let's do this we're going to say terminal and we're going to say that we want to run a task but this time we want to build with msvc this is what we want to do here if we click on this little thing we're going to kick off the process to build with the compiler from microsoft and we're going to wait for the compiler to do its thing and if we wait we're going to see that the world finished successfully and if

52:25 we look in our folder we're going to see that we have our output file and we can come in our terminal and hit to enter and do clear to clear things up and if we say rooster just like this and hit enter you're going to see that it's going to say zero and this is confirmation that we are able to use our visual studio code editor and be able to use it with all kinds of crazy compilers and this is really cool if you are on windows i recommend setting this up because it's it's going to make it easier to run a c plus plus applications from visual studio code using state-of-the-art compilers like msvc clone and gcc here and this is really cool now we have everything we need to start running c plus plus applications

53:12 but before i let you go let's show you how you can set this up so that you have an easier time with regards to intellisense and whatever so what we're going to do we're going to go to our view menu and we're going to choose command palette and in this we're going to say c or c plus plus we can say something like this and we're going to choose edit configuration ui this is going to give us an option to configure things and i want you to configure things your new system so i am on a windows system let's see the options we have here i am only going to have the option for win32 but if we go down we can specify the things we need visual studio code configured for for example it's going to give us

53:57 intellisense or autocomplete and all kinds of greater things using the setting we choose here if we want we can choose the gcc compiler or whatever i am just going to leave in the windows msvc compiler because i am on windows here but know that you can configure these things now if we go down we're going to see that we have the option to configure the c plus plus standard and the compiler path that is going to be used to figure things out we're going to be using the compiler from microsoft here but know that you have the option to choose any other compiler for example we can choose the g plus plus compiler we can choose the clank plus class compiler you can configure these things and if you need to change this please come back here and do these configurations here we're going to leave in this whole intellisense and what we will do

54:43 is configure visual studio code to use the c plus plus 20 standard so we're going to do that right here and if you set this up you're going to see that visual studio code is going to generate a cpp properties file which is going to store all these configurations here so it is really going to be a configuration for what we choose in our configuration here so make sure you choose what makes sense again i would recommend using c plus plus 20 but if you go on top you can really use any compiler you want i am going to use the compiler from microsoft this is okay i am going to use windows msvc configuration for intellisense here and i am going to close this and we are really ready to start using visual studio code to ride c plus plus

55:28 application so let's clean this up a little bit we're going to view our terminal and we're going to remove the junk that was generated by the compiler from microsoft i am going to say rm and say rooster and i can remove the binary i can say rm and say rooster and say tab this is going to autocomplete and really remove things i don't need i am going to remove the pdb file i am going to remove rooster you know i am going to remove the main object file so let's say main dot obj and i am going to remove main dot or vc we don't want to remove our cpd file so now we have a project we can use as a starting point to write c and c

56:16 plus plus applications here so what we will be doing in the next few lectures or the next few chapters is reusing this thing here as a template project so what i can do is uh call this c plus plus 20 template project and let's do this here i think i need to close video studio code otherwise it's going to complain so i am going to call this little guy c plus plus 20 template project and later when we start learning about c plus plus proper we're going to be using this as a starting point and we want to have to reconfigure the compilers our project will be ready to use the compilers that we set up here namely the compiler from microsoft the g plus plus compiler and the clang plus plus

57:03 compiler and that's going to be really cool this is really all i have to share in this lecture i hope you have visual studio code set up to use all these compilers we are going to stop here in this lecture the next one we're going to start and see how to set up your development environment on linux and we're going to start by installing compilers on ubuntu 2004 go ahead and finish up here and meet me there in this lecture we're going to see how to install c plus plus compilers on linux we are going to be working on an ubuntu 2004 system and we will install a new version of gcc and the latest version i can get my hands on for clang llvm so let's do this okay so here i am on my linux box this is ubuntu 2004 if i

57:52 do you name and say a we're going to see the information on this and you will have to adapt this for whatever linux distribution you are on and to install gcc it's really simple but the problem is the latest version of gcc at the time of recording this video is gcc 11 and it's not available in the ubuntu packages now for example if you do see do apt get install gcc 11 this is how you get it if you do this you're going to put in your password you're going to see that this is really not available yet right we cannot find this so the best version we can install is gcc 10 which i happen to have

58:38 installed already on this system so we're going to do gcc 10 that's what we're going to install here and if we do this we're going to see that this is already available you can also install g plus plus done i think you can do that okay so we're going to run the command here and we're also going to see that it's already available here but if you don't have these they are going to be installed and you can use them on your linux system another tool that is necessary on linux is the gdb debugger so we're going to do sudo apt get install gtb right if you install it it's going to be installed but i already have it installed already so now if i do gcc 10 on my system here and say version we're

59:25 going to see the version printed out we can do g plus plus stand we can see the version here let's do that for c plus plus so we're going to see the version here we can even do gdb version and it is going to show up let's wait for this we're going to see my gdp version here and now i can use these compilers to compile c plus plus code on my linux box here so this completes our steps to install a gcc compiler on linux we're going to look at how we can get a hold of the clang compiler on our linux box here and it is really simple all you have to do is to do apt get install and we're going to install clang 12 because that's the latest version at the

1:00:12 time of recording this video if we do this we're going to see that it's going to install i already have it installed here but if you don't have it installed it's going to install on your system and this is going to give you all the tools you need to compile with the clan compiler on this particular ubuntu system these installs are going to be installed in my user bin directory so if i see the there and do analysis to show everything in here and scroll up we're going to find all the versions for clan you see i have multiple versions clang 10 11 12 and we have clan plus plus variance of this i think we do okay we have clank plus plus and clan here and this is going to do what we want we have the clan combiner and the gcc compiler

1:00:58 installed on our system here now if you want to get the latest version of gcc installed on your system one easy way i found is to go through a package manager called homebrew let's search for this right if you search for this you're going to find it and if you want you can install it on your linux system and when you install it it's going to to be basically there ready to use and to install it i think there's a command there install home brew let's do this install here and if we do install we should find a link to install this let's find a link i think they have a link you can copy aha it is this little thing here you can copy it paste it in your terminal and it is going to install

1:01:44 home brew on your system and when you have home brew installed you can go through it to install the latest version of gcc for example if we search for homo blue gcc in our search engine here we're going to find all the information to install this through home brew and you just have to do bro install gcc and this is going to install this on your system and you're going to see that it is going to install the latest version at the time of recording this video so this is what you should do for example if we go back to our linux box we can do let's cd into our home directory and we're going to say brew install gcc and it's going to tell me that it is already installed because i installed

1:02:30 this but if you don't have it installed it's going to install it and you do this after you have gone through the steps to install the home brew package manager on your system and you do that by just copying this link and pasting that in your terminal and hitting enter and it's going to give you directions on what you can do to get this properly installed on your system here so this is really cool so if you want the absolute latest version in gcc this is one way you have to get a hold of it without really going through the complex steps to build the compiler yourself on linux okay it is taking some more time here i am just going to kill this because i already have the latest version of gcc here if i do jcc 11 on linux and the do version

1:03:19 i am going to see that i have 11 2 and it was installed through homebrew and if you let this run to completion it's going to install this on your computer we don't have to wait for this so now we have the latest version of gcc on an ubuntu system we also have the latest version of clan this completes our tutorial on how to set up compilers on linux we are going to stop here in this lecture this one we're going to install visual studio code on the linux system and then in the next one we're going to link visual studio code to these compilers and be able to use visual studio code type code and compile our programs using these two compilers here so go ahead and finish up here and meet me in the next lecture in this lecture we're going to see how

1:04:05 to install the visual studio code editor on a linux system and again we will be working on our ubuntu 2004 system here so let's head over to the website for visual studio code and download our binary and install it on our linux system here okay so here we are at the website for visual studio code you can get there by searching for visual studio code in your search engine and you're going to land here and all we really have to do is go down to find our download links we're going to see that for debian and ubuntu we can download here but you can also find something specific to other distribution okay so we are going to grab the 64-bit version of debian ubuntu here because that's my system and you're

1:04:51 going to find whatever makes sense for your distribution so let's grab this here we're going to grab the link so if you click on this this is going to kick off the download process and you will see this downloaded on your system and once you have this downloaded you're going to install it and in ubuntu you can just double click on this to install it or you can install it like you install any debian package on a linux system for example if you are unsure on how to install debian packages all you have to do is do a simple search so let's do google.com and go there and we're going to see how to install to install debian packages on ubuntu 2004 so this is our version here and

1:05:38 you're going to find a lot of instructions on how to do this it's going to be really simple so we can go

…

Share

More video summaries