Learn C++

Design

Scope
Header Guards
                Approaches to Programming Design:
                1. Procedural Design Approach
                    Fortran, Assembly C
                    Top-Down Desing, Bottom-Up Implementation
                    can solve any problem with this approach
                    build a program by combining algorithms
                    algorithms work on data passed between them from function to function
                    input/output
                    how to get from input to output
                    break complex tasks into smaller pieces
                    design functions to achieve these pieces
                    issues: scaling
                2. Object-Oriented Approach
                    C++, Java, Python
                    object: entity using data and behavior, may comprise other objects, has properties, can do things and have things done to it
                    program consists of interacting objects
                    design: identify objects and determine how objects need to interact
                    determine data
                    determine represention of data as object(s)
                    define interactions between objects
                3. Functional Approach  
                    Haskel, Clojure, F#
            
Back to Top

Scope


Call Stack
Back to Top

Memory

                Visualization of Memory with Pointers
                Dynamic Memory

                Memory Management
            

Back to Top

Compiling/Linking

Compiling and Linking
Back to Top

Projects

                Files

                Unit Testing
                
                Headers (.h)
                    doctest.h
                    main.h
                
                Source (.cpp)
                    main.cpp
                    tester.cpp
            

Back to Top

Files

                Separating Class Definition from Class Implementation
                header file (.h) contains the class definition (simply list the data fields, constructor prototypes, function prototypes)
                source file (.cpp) contains the class implementation of the constructors and functions
                both the .h and .cpp should have the same file name
            
                preprocessor directives
                    to prevent a header file from being included multiple times:
                    #indef  // @ top 
                    #define  // @ top
                    #endif  // @ bottom
            
Back to Top

I/O Formatting

                set width
                set precision
                set fill
            

Back to Top

Unit Testing

Why Unit Testing? Unit Testing Guide Thorough Guide
Back to Top

Doxygen Comments


Back to Top

UML

                helper in designing classes
            

Back to Top

Classes


Back to Top

Constructors

a special kind of function which initializes an object no return type

class naming nomenclature

                it must initialize all member variables
                automatically called when object is declared
                default constructor does nothing and has no arguments
                overloading a function is providing multiple versions of the function with different Parameters
                may overload a constructor
                parameters in the function call determine which function is used
                // use no-arg constructor
                Circle c1;
                // use one-arg constructor
                Circle c2(5.5);
                // use n-arg constructor
                Circle c3(5.5, 10);  // n = 2
                avoid shadowed names, instead i.e. use m_ to proceed names of member variables
                example:
                private:
                    double m_radius;
                Circle::Circle(double radius) {
                    m_radius = radius;
                }
            

Back to Top

Objects


Back to Top

Syntax

                comments
                    //  single line
                    /*  multi-line
                    /** machine readable
                    
                typedef

                namespaces
                    using namespace std;
                    Namespaces
                    Typedefs

                preprocessor directives
                    Intro to
                    Header Files
                    anything that starts with a #
                    #include <>iostream
                    #ifndef  // if not defined
                    #define
                    #endif  // indicates end of header file
                    
                    
            

Back to Top

Pointers


Back to Top

Data Types

                struct Structy {

                };
                
                class Classy {

                };

                strings


            

Back to Top

Variables


Back to Top

Data Structures

                Linear
                    Tree
                    Graph

                Non-Linear
                    Static
                        Array
                    Dynamic
                        Queue
                        Stack
                        Linked List
            

Back to Top

Arrays

                1-D

                Matrix
            

Back to Top

Structs

Structs, Members
Back to Top

Conditionals


Back to Top

Loops

                while loop

                do while loop

                for loop

                for each loop
            

Back to Top

Functions

                pow()
                rand()
                time(0)
            

Back to Top

Reference Parameters


Back to Top

Enumerations


Back to Top

Operators

                stream insertion operators
                    cout <<
                stream extraction operators 
                    cin >> 
            

Back to Top

Recursion


Back to Top

Debugging

DEBUGGING 1
DEBUGGING 2
STRING DEBUGGING
Back to Top

Commands

Commands Windows Mac/Linux
                mkdir           create a new directory
                cd              move into directory (make current)
                ..              move up one directory
                ls              list items in directory
            
                compile a main program from the command line:
                g++ Circle.h Circle.cpp TestCircleWithHeader.cpp -o Main
            

Back to Top

IDE

                Visual Studio Code
                    CTRL-B          toggle side bar
                    CTRL-/          comment out a line

                PyCharm
                    CTRL-/          comment out a line

                QT Creator
                    Short Term Code Box
                    Installation
                    Installation Video Guide
                    CTRL-S          save
                    CTRL-B          build
                    CTRL-R          run
                    CTRL-/          comment out a line
            

Back to Top

HTML

jump button
Back to Top