CS 128 C++ functions

This post contains some functions of C++ in addition to its basic usage.

std::vector<type> vector = {1, 2, 3, 4, 5};
vector.size();
vector.push_back();

std::map<type, type> map = {{1, "Cat"}, {2, "Panda"}};
map.insert(std::pair<type, type>(key, value));
map.insert({key, value});
for (auto const& [key, value] : map) {}
for (std::pair<, > : map) {}
map.size()
map.contains(check_key);
map.at(check_key);

set.size()
set.contains()
set.erase()

#include <fstream>

int main( int argc, char *argv[] )  {}


std::ifstream ifs{fileName};
ifs.good();
ifs.bad();
ifs.fail();
ifs.eof();

https://www.runoob.com/cplusplus/cpp-files-streams.html

Last Updated on 1 year by Yichen Liu