class custom_cmp    {
public:
	custom_cmp(const map<int, double> &_cmptable):cmptable(_cmptable){}
	bool operator()(const int &lhs, const int &rhs)
	{
		if(cmptable[lhs] > cmptable[rhs])
			return 1;
		else if(cmptable[lhs] == cmptable[rhs])
			return lhs < rhs;
		else return 0;
	}
	map<int, double> cmptable;
};

class A
{
public:
    // 如何在宣告class A object時也建立好內部map成員的比較函式
    // 像main function宣告的方式一樣
	A(const map<int, double> &_cmptable):cmptable(_cmptable){}
	
    map<int, double> cmptable;
    // 底下不行這樣寫
	custom_cmp cmpobject(cmptable);
	map< int, shared_ptr<char>, custom_cmp> header(cmpobject);
};

int main(int argc, char *argv[])
{
    // 在main function內這樣宣告可以
    map<int, double> cmptable;
    custom_cmp cmpobject(cmptable);
    map< int, shared_ptr<char>, custom_cmp> header(cmpobject);
    
    // 想在宣告A的物件時, Aobj內的header可根據cmptable來排序
    A Aobj(cmptable);
    
    return 0;
}