CHAPTER4-17.cpp
上传用户:fjc899
上传日期:2007-07-03
资源大小:187k
文件大小:1k
- //文件夹名称:CHAPTER4-17.cpp
- #include<iostream.h>
- #include<afx.h>
- #include<afxcoll.h>
- #define NUMBER 5
- class A:public CObject
- {
- int age;
- public:
- A(int x):age(x){}
- void operator!(){cout<<age<<endl;}
- };
- void main()
- {
- int x=-1;
- CObList list;
- A *p[NUMBER];
- cout<<"Please input "<<NUMBER<<" integers"<<endl;
- for(int i=0;i<NUMBER;i++)
- {
- while(x<0)cin>>x;
- p[i]=new A(x);
- list.AddHead(p[i]);
- x=-1;
- }
- cout<<"The total number is "<<list.GetCount()<<endl;
- !*((A*)list.GetHead());
- if(list.Find(p[2]))!*p[2];
- !*((A*)list.GetAt(list.FindIndex(3)));
- cout<<flush;
- cin.get();
- list.RemoveAll();
- }