C++
ph
목차
--start-group, --end-group
Thus the order libA libB (where libB depends on libA) will trigger the error, but libB libA will be ok. If both libraries have mutual dependencies, then either use libA libB libA or use --start-group and --end-group linker flags, where the linker will go round and round the group of files until all unresolved symbols have been found.
http://stackoverflow.com/a/35927747/766330
Exceptions and Error Handling
https://isocpp.org/wiki/faq/exceptions 조금 긴데 읽어볼 가치가 있다.
Flushing stdout
fflush(stdout);
or
setbuf(stdout, NULL);
https://stackoverflow.com/a/1716621/766330
Basics
sort
// sort algorithm example
#include <iostream> // std::cout
#include <algorithm> // std::sort
#include <vector> // std::vector
bool myfunction (int i,int j) { return (i<j); }
struct myclass {
bool operator() (int i,int j) { return (i<j);}
} myobject;
int main () {
int myints[] = {32,71,12,45,26,80,53,33};
std::vector<int> myvector (myints, myints+8); // 32 71 12 45 26 80 53 33
// using default comparison (operator <):
std::sort (myvector.begin(), myvector.begin()+4); //(12 32 45 71)26 80 53 33
// using function as comp
std::sort (myvector.begin()+4, myvector.end(), myfunction); // 12 32 45 71(26 33 53 80)
// using object as comp
std::sort (myvector.begin(), myvector.end(), myobject); //(12 26 32 33 45 53 71 80)
// print out content:
std::cout << "myvector contains:";
for (std::vector<int>::iterator it=myvector.begin(); it!=myvector.end(); ++it)
std::cout << ' ' << *it;
std::cout << '\n';
return 0;
}
[start, end) 으로 범위를 주고 비교함수는 오름차순 정렬기준.
vector
pair vector
revenue.push_back(std::make_pair("string",map[i].second));