In this tutorial, I will teach the whole C++ programming language in a video tutorial. The memo sheet is shown in the video below.
This covers data types, arithmetic, If, switches, ternary operators, arrays, For loops, While loops, Do While loops, user input, strings, vectors, functions, recursion, file I/O, exceptions, parts of pointers, reference operators, classes, objects, private, public, prototype, static, encapsulation, Constructors, destructors, heredity, virtual methods, polymorphism, abstract data types, etc.
Video C++ Programming download (see https://via-dean.com)
Memorandum, Part 3:
Part I (excerpts):
// This is a comment /* * Multi-line comment */ // Tells the compiler iostream library which contains the function cout #include <iostream> // Allows us to use vectors #include <vector> // Allows us to use strings #include <string> // Allow us to work with files #include <fstream> // Allows functions in the std namespace to be used without their prefix // std::cout becomes cout using namespace std; // ---------- FUNCTIONS ---------- // The function has return type, function name and attributes with // their data types // The attribute data types must match the value passed in // This data is passed by value // You can define default values to attributes as long as they come last // This is known as a function prototype int addNumbers(int firstNum, int secondNum = 0){ int combinedValue = firstNum + secondNum; return combinedValue; } // An overloaded function has the same name, but different attributes int addNumbers(int firstNum, int secondNum, int thirdNum){ return firstNum + secondNum + thirdNum; } // A recursive function is one that calls itself int getFactorial(int number){ int sum; if(number == 1) sum = 1; else sum = (getFactorial(number - 1) * number); return sum; // getFactorial(2) [Returns 2] * 3 // getFactorial(1) [Returns 1] * 2 <This value goes above> // 2 * 3 = 6 } // Doesn't have a return type so use void // Since I'm getting a pointer use int* // Refer to the referenced variable with *age void makeMeYoung(int* age){ cout << "I used to be " << *age << endl; *age = 21; } // A function that receives a reference can manipulate the value globally void actYourAge(int& age){ age = 39; } // ---------- END OF FUNCTIONS ---------- // ---------- CLASSES ---------- // classes start with the name class class Animal { // private variables are only available to methods in the class private: int height; int weight; string name; // A static variable shares the same value with every object in the class static int numOfAnimals; // Public variables can be accessed by anything with access to the object public: int getHeight(){return height;} int getWeight(){return weight;} string getName(){return name;} void setHeight(int cm){ height = cm; } void setWeight(int kg){ weight = kg; } void setName(string dogName){ name = dogName; }