Loading...

Go Back

Next page
Go Back Course Outline

C++ Full Course


Introduction to C++

Introduction to C++ Programming

1. History & Evolution of C++

StandardYearKey Features
C++981998First standardized version (templates, exceptions, STL)
C++112011auto, lambda expressions, smart pointers
C++142014Binary literals, generic lambdas
C++172017Structured bindings, filesystem library
C++202020Concepts, ranges, coroutines
C++232023mdspan, stacktraces, std::print

C++11 Example

#include 
#include 

int main() {
    std::vector numbers = {1, 2, 3};
    for (auto num : numbers) {
        std::cout << num << " ";
    }
    return 0;
}
1 2 3


2. Compilation Process

Four Stages

  1. Preprocessing (handles #includes and macros)
  2. Compilation (converts to assembly)
  3. Assembly (creates object files)
  4. Linking (combines object files)

Compiler Examples

# GCC
g++ -o program program.cpp
./program

# Clang
clang++ -o program program.cpp
./program

3. Your First C++ Program

#include 

int main() {
    std::cout << "Hello, World!" << std::endl;
    return 0;
}
Hello, World!

Compilation & Execution

g++ -o hello hello.cpp
./hello


4. Common Pitfalls & Best Practices

  • ✅ Avoid using namespace std;
  • ✅ Always return 0 explicitly from main()
  • ✅ Use header files (.hpp) for declarations
  • ❌ Don't ignore compiler warnings

Summary

ConceptDescription
Compilation4-stage process to executable
main()Mandatory entry point
std::coutStandard output stream
NamespacesPrevent naming conflicts

Next Steps

Go Back

Next page