📄 main.cpp
字号:
#include <iostream>
#include <stdlib.h>
#include <map>
#include <string>
using namespace std;
class MyClass {
public:
string Name;
};
class MyLess {
public:
bool operator()(const MyClass &x,
const MyClass &y) const {
return x.Name < y.Name;
}
};
int main(int argc, char *argv[])
{
map<int,int> A;
A[0] = 1;
A[1] = 2;
A[2] = 4;
map<int,int,less<int> > B;
B[0] = 10;
B[1] = 20;
B[2] = 40;
map<MyClass, MyClass, MyLess> C;
MyClass key1 = {"Harold"};
MyClass value1 = {"123"};
MyClass key2 = {"Lloyd"};
MyClass value2 = {"952"};
C[key1] = value1;
C[key2] = value2;
cout << C[key2].Name << endl;
system("PAUSE");
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -