📄 chapter4-18.cpp
字号:
//文件夹名称:CHAPTER4-18.cpp
#include<afx.h>
#include<afxcoll.h>
#include<iostream.h>
class A:public CObject
{
WORD age;
public:
A(WORD x):age(x){}
WORD operator!(){return age;}
};
void main()
{
WORD l=0,k;
A *p;
CMapWordToOb map;
for(int i=0;i<5;i++)
{
while(l==0)cin>>l;
if(i==3)k=l;
p=new A(l);
map.SetAt(!*p,(A*)p);//如果键值相同,则以新换旧
l=0;
}
cout<<"The total number is "<<map.GetCount()<<endl;
if(map.Lookup(k,(CObject*&)p))cout<<!*p;//如果返回值不为零则p将得到该对象的地址
cout<<flush;
cin.get();
map.RemoveAll();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -