14_1.cpp
资源名称:c.rar [点击查看]
上传用户:puke2000
上传日期:2022-07-25
资源大小:912k
文件大小:0k
源码类别:
C#编程
开发平台:
Visual C++
- //14_1
- #include <iostream.h>
- class Samp{
- public:
- void Setij(int a, int b){i=a,j=b;}
- ~Samp(){ cout <<"Destroying.." <<i <<endl; }
- int GetMulti(){ return i*j; }
- protected:
- int i;
- int j;
- };
- void main()
- {
- Samp* p = new Samp[10];
- if(!p){
- cout <<"Allocation errorn";
- return;
- }
- for(int j=0; j<10; j++)
- p[j].Setij(j,j);
- for(int k=0; k<10; k++)
- cout <<"Multi[" <<k <<"] is:"
- <<p[k].GetMulti() <<endl;
- delete[]p;
- }