C/C++ Arena

C vs C++: what's the difference?

How C++ builds on C with classes, references, RAII, templates and the standard library, and when each language is used.

C++ started as "C with classes" and almost all C code is also valid C++. What C++ adds:

C is still the language of operating system kernels, embedded firmware and libraries that every other language calls. C++ dominates games, browsers, databases, trading systems and high-performance applications. Learning C first makes C++'s features make sense, which is why this course does it in that order.

Example

#include <iostream>
#include <string>
#include <vector>

int main() {
    std::vector<std::string> names{"Ada", "Linus"};
    names.push_back("Bjarne");
    for (const auto &n : names) std::cout << n << " ";
    std::cout << "\n";
    return 0;
}

Output:

Ada Linus Bjarne 

Practice it