| 필요할때마다 잊는지라, 이곳에 메모해 봅니다.. ^^ #include <map>
using namespace std;
class Standard {
private:
int a;
public:
Standard(int a) {
this->a = a;
}
int Get() {
return a;
}
};
class Value {
public:
Standard *pStandard;
Value(Standard *pStandard) {
this->pStandard = pStandard;
}
};
class CustomCompare {
public:
bool operator()(Standard* s1, Standard* s2) const {
return s1->Get() == s2->Get();
}
};
int main(int argc, _TCHAR* argv[])
{
map<Standard*, Value*, CustomCompare> container;
Standard *pStand1 = new Standard(10);
Value *pValue1 = new Value(pStand1);
Standard *pStand2 = new Standard(20);
Value *pValue2 = new Value(pStand2);
container[pStand1] = pValue1;
container[pStand2] = pValue2;
Standard *pStand3 = new Standard(20);
printf("%d\n", container[pStand3]->pStandard->Get());
delete pStand3;
delete pStand1;
delete pStand2;
delete pValue1;
delete pValue2;
return 0;
}
|