C++ code examples
6 short, tested snippets. Pick one to see the code with notes, or search Zest for something specific, such as “cpp loop over a vector”.
- Loop over a vectorstd::vector<int> v = {1, 2, 3};
- Read a file line by line#include <fstream>
- Lambda and std::sortstd::vector<int> v = {3, 1, 2};
- Smart pointers#include <memory>
- Map iterationstd::map<std::string, int> m = {{"a", 1}, {"b", 2}};
- Hello world#include <iostream>