⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chapter4-16.cpp

📁 C++STL程序员开发指南
💻 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 + -