📄 chapter4-16.cpp
字号:
//文件夹名称:CHAPTER4-16.cpp
#include<iostream.h>
#include<afxcoll.h>
#include<afxtempl.h>
class A
{
int age;
public:
A(){}
A(int x):age(x){}
void operator!(){cout<<age<<endl;}
void operator=(int x){age=x;}
};
void main()
{
A *p;
int l,c[5];
CArray<A,A> array;
for(int i=0;i<5;i++)
{
cout<<"Please input Age data:";
cin>>l;
p=new A(l);
c[i]=array.Add(*p);//返回索引值
}
cout<<"The current total number is "<<array.GetSize()<<endl<<"The second item is ";
!array.GetAt(c[2]);//返回被插入的对象
array.InsertAt(0,*new A(100),2);//向数组的最前端插入两个新对象
cout<<"The current total number is "<<array.GetSize()<<endl<<"The second item is ";
!array[2];
array[2]=99;
cout<<"The second item modified is ";
!array[2];
cout<<flush;
cin.get();
cin.get();
array.RemoveAll();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -