Skip to content
  • Introduction to C++ · C++

Introduction to C++

LearnViaNotes @learnvianotes· 2 min read

A compiled, statically typed, multi-paradigm language that gives you C-level control of memory with high-level abstractions that cost nothing at run time.

Why C++?

C vs C++

FeatureCC++
ParadigmProceduralProcedural + OOP + generic + functional
StructsData onlyclass/struct with methods, access control, inheritance
Memorymalloc / freenew / delete, but prefer containers & smart pointers
Stringschar* + <string.h>std::string, std::string_view
Pass byValue or pointerValue, pointer or reference (int&)
OverloadingNoFunction & operator overloading
Generic codeMacros / void*Templates, concepts
ErrorsReturn codes, errnoExceptions (plus return codes, std::optional)
NamespacesNo (one global scope)namespace
Standard librarySmall (stdio, stdlib…)STL: containers, algorithms, threads, chrono, …

Your first program

C++
#include <iostream>

int main() {
    std::cout << "Hello, C++!\n";
    int year = 2020;
    std::cout << "Standard: C++" << year % 100 << '\n';
    return 0;   // optional in main: falling off the end returns 0
}
Output
Hello, C++!
Standard: C++20

The standards

StandardHeadline features
C++98/03STL, templates, exceptions, std::string
C++11The “modern C++” reset: auto, lambdas, move semantics, nullptr, smart pointers, range-for, constexpr, threads
C++14Generic lambdas, make_unique, relaxed constexpr
C++17Structured bindings, optional/variant/any, string_view, if constexpr, filesystem
C++20Concepts, ranges, coroutines, modules, <=>, std::format, std::span
C++23std::print, std::expected, ranges::to, deducing this

Is C++ an object-oriented language?

Why is C++ faster than Java or Python?

Free for students and teachers

Write notes like this one

Cards for every idea, quizzes and flashcards, read aloud — on the web and your phone.

Something wrong with this note? Open it to report