C++ Tutorial for Beginners - Full Course

Share

Summary

This comprehensive C++ tutorial for beginners covers everything from setting up your development environment to understanding core programming concepts like variables, functions, and object-oriented programming. Learn to write simple programs, build a calculator and a guessing game, and explore advanced topics like pointers, classes, and inheritance.

Highlights

Introduction to Functions
1:20:09

Functions are explained as reusable blocks of code performing specific tasks. This section demonstrates how to define a function (e.g., `SayHi`) with a `void` return type, pass parameters (e.g., `string name`, `int age`), and call the function from the `main` function. It also covers declaring function prototypes forward.

Understanding Arrays
1:13:53

Arrays are introduced as containers that can hold multiple data values of the same type. Covered topics include declaring and initializing integer arrays, accessing individual elements using zero-based indexing (e.g., `lucky_nums[0]`), modifying array elements, and specifying array size during declaration.

Introduction to C++
0:00:00

This section introduces C++ as a popular and powerful programming language, closely related to C. The course will cover core concepts, starting with setup and basic programs, then moving to advanced topics like variables, data types, control structures, and object-oriented programming.

Setting Up Your C++ Development Environment (Windows)
0:01:42

Learn how to get started with C++ development by installing necessary tools. This includes setting up a text editor, specifically an Integrated Development Environment (IDE) like Code::Blocks, and a C++ compiler. The tutorial demonstrates downloading Code::Blocks, which bundles a compiler (MinGW), for Windows users.

Setting Up Your C++ Development Environment (Mac)
0:04:59

This segment guides Mac users through setting up their C++ development environment. It covers checking for and installing the GCC compiler via Xcode command-line tools in Terminal, and then downloading and installing the Code::Blocks IDE for writing C++ code.

Creating Your First C++ Project
0:08:50

Learn to create and run your first C++ project in Code::Blocks. This involves starting a new console application, naming the project, and understanding the basic 'Hello World' program. The process of building and running a C++ program is explained, differentiating between compilation and execution.

Basic C++ Program Structure
0:12:32

This part breaks down the basic structure of a C++ program, explaining `iostream` and `namespace std`. It introduces the `main` function as the entry point for execution and demonstrates printing text to the console, including using `std::endl` for new lines and drawing a simple ASCII triangle.

Working with Variables
0:19:58

Variables are introduced as containers for storing data. The tutorial illustrates their utility by demonstrating how to store and manage character names and ages in a story, making it easier to update information. It covers declaring string and integer variables and incorporating them into print statements.

C++ Data Types
0:31:48

A detailed explanation of various C++ data types: `char` for single characters, `string` for text, `int` for whole numbers, `float` and `double` for decimal numbers (with `double` offering more precision), and `bool` for true/false values. It also clarifies the concept of constants versus variables.

Working with Strings
0:39:20

This section focuses on string manipulation. It covers printing strings, using `\n` for new lines, storing strings in variables, and introduces string functions like `.length()` to get string length, accessing individual characters by index, modifying characters, and using `.find()` and `.substr()` for searching and extracting substrings.

Working with Numbers
0:49:03

Explore various operations with numbers in C++. This includes basic arithmetic (+, -, *, /) and the modulus operator (%). It also explains order of operations, integer vs. decimal division, and introduces math functions (from `<cmath>`) like `pow()` (power), `sqrt()` (square root), `round()`, `ceil()`, `floor()`, `fmax()`, and `fmin()`.

Getting User Input
0:59:46

Learn how to obtain input from the user in C++. This involves declaring variables to store the input, prompting the user with `std::cout`, and using `std::cin` to read numbers (`int`, `double`, `char`). For reading entire lines of text (strings), the `getline()` function is introduced as a more suitable option.

Building a Basic Calculator
1:05:36

A practical application of user input and basic arithmetic: building a simple calculator. The tutorial guides through getting two numbers from the user, adding them, and printing the result. It highlights the correct usage of `std::cin` with `>>` operators and demonstrates how to use `double` for decimal calculations.

Building a Mad Libs Game
1:09:30

Create an interactive Mad Libs game using user input and string variables. The game prompts the user for a color, plural noun, and celebrity name, then inserts these words into a predefined story, demonstrating how to print variables within text for humorous results.

Function Return Values
1:29:54

This tutorial shows how functions can return values to the caller. It illustrates this by creating a `cube` function that takes a `double` as a parameter, calculates its cube, and returns the result. The concept of a return type (e.g., `double`) and the `return` keyword are thoroughly explained, emphasizing that `return` exits the function.

If Statements
1:35:27

If statements are presented as a control structure to execute code conditionally. The tutorial demonstrates using `if`, `else`, and `else if` to respond to different scenarios based on boolean variables (`is_male`, `is_tall`). It also covers the AND (`&&`) and OR (`||`) logical operators, and the negation operator (`!`) for complex conditions.

If Statements with Comparisons
1:47:19

Building upon basic if statements, this section explores using comparison operators (`>`, `<`, `>=`, `<=`, `==`, `!=`) within if conditions. A `GetMax` function is created to find the largest of two or three numbers, showcasing how to use logical AND (`&&`) to combine multiple comparison conditions for more complex decision-making.

Building a Better Calculator
1:56:01

This tutorial guides you through building an enhanced calculator that supports addition, subtraction, division, and multiplication. It demonstrates how to get two numbers and an operator from the user, then uses a series of `if/else if/else` statements to perform the correct calculation based on the entered operator, handling invalid input gracefully.

Using Switch Statements
2:02:28

Learn about switch statements as an alternative to lengthy `if/else if` chains for evaluating a single variable against multiple possible values. An example function `GetDayOfWeek` is built to convert a number (0-6) into a day name. It covers `case` labels, the `break` keyword to exit the switch, and the `default` case for unmatched values.

While Loops
2:10:54

While loops are introduced as a programming structure for repeatedly executing a block of code as long as a specified condition remains true. The concept of an 'indexing variable' is explained. The tutorial also highlights the danger of 'infinite loops' and introduces the `do-while` loop, which guarantees at least one execution of the loop body before checking the condition.

Building a Guessing Game
2:18:56

Combine `while` loops, `if` statements, and variables to create a number guessing game. The game challenges the user to guess a secret number. The tutorial enhances the game by adding a 'guess limit' feature, using counters and boolean flags (`out_of_guesses`) to manage attempts and determine win/loss conditions.

For Loops
2:29:21

For loops are presented as a specialized loop for iterating a known number of times, commonly used with an indexing variable. The tutorial contrasts for loops with while loops, demonstrating a more compact syntax for initialization, condition checking, and incrementing. It specifically shows how to use for loops to iterate through and print elements of an array.

Building an Exponent Function
2:39:36

This segment demonstrates using a `for` loop to build a custom `power` function that calculates a base number raised to a given exponent. The function takes two integer parameters (`base_num` and `pow_num`) and uses a loop to repeatedly multiply the base, returning the result. It clarifies how the loop iterates `pow_num` times to achieve the exponentiation.

2D Arrays and Nested For Loops
2:45:26

Explores two advanced concepts: 2D arrays (arrays of arrays) and nested for loops (a for loop inside another for loop). The tutorial shows how to declare, initialize, and access elements in a 2D array, likening it to a grid or matrix. It then demonstrates how nested for loops can be used to efficiently iterate through and process every element in a 2D array.

Comments in C++
2:54:59

Discusses the use and importance of comments in C++ code. It covers two types of comments: single-line comments (`//`) and multi-line comments (`/* ... */`). The tutorial explains how comments are ignored by the compiler and are used by programmers for documentation, explanations, or temporarily disabling code.

Understanding Pointers
2:59:20

Pointers are introduced as variables that store memory addresses. The tutorial explains how variables are stored in computer memory (RAM) at unique addresses. It demonstrates how to get the memory address of a variable using the ampersand operator (`&`) and how to declare pointer variables (e.g., `int *p_age`) to store these addresses. The concept of 'dereferencing' a pointer (`*p_age`) to access the value at the stored address is also covered.

Classes and Objects
3:13:30

This section introduces Object-Oriented Programming concepts: classes and objects. A class is defined as a blueprint or template for creating custom data types (e.g., a `Book` class), which can have various attributes (e.g., `title`, `author`, `pages`). An object is an actual instance of a class derived from that blueprint. The tutorial demonstrates how to create `Book` objects and assign values to their attributes.

Class Constructors
3:25:50

Constructors are special functions within a class that are automatically called when an object of that class is created. The tutorial demonstrates how to define a constructor for the `Book` class to initialize object attributes directly upon creation (e.g., `Book book1("Harry Potter", "JK Rowling", 500)`). It also shows how to create multiple constructors for different initialization scenarios.

Object Functions
3:34:44

Object functions (or instance methods) are introduced as functions that operate on the data specific to an object. Using a `Student` class example, the tutorial demonstrates creating a `has_honors()` function that checks a student's GPA to determine if they qualify for the honor roll. This highlights how an object's function uses its own attributes (GPA) to perform a task, and how changes to logic in the class affect all objects consistently.

Getters and Setters
3:41:48

Getters and setters are explored as methods to control access and modification of object attributes. Using a `Movie` class, the tutorial demonstrates setting attributes (like `rating`) as `private` to prevent direct access, and then creating public `get_rating()` (getter) and `set_rating()` (setter) functions. The `set_rating()` function includes validation logic to ensure only acceptable ratings are assigned, improving data integrity.

Inheritance
3:54:08

Inheritance is explained as a mechanism where one class (subclass, e.g., `ItalianChef`) can inherit properties and behaviors from another class (superclass, e.g., `Chef`). The tutorial shows how an `ItalianChef` can perform all actions of a `Chef` while also adding unique functionalities (e.g., `make_pasta`) and overriding inherited functions (e.g., `make_special_dish`) to provide specialized behavior.

Recently Summarized Articles

Loading...