// 習題五.3.cpp: 定義控制臺應用程式的入口點。
//
#include "stdafx.h"
#include <iostream>
using namespace std;
class Test
{
private:
int x, y;
public:
Test(int a = 0, int b = 0) :x(a), y(b) {}
void Set(int a, int b)
{
x = a;
y = b;
}
void Show()
{
cout << '(' << x << ',' << y << ')' << ends;
}
~Test() { cout << "destructor(" << x << ',' << y << ')' << endl; }
};
int main()
{
Test *p[3] = { new Test(1,2), new Test(3,4), new Test(5,6) };
//cout << p << endl;
for (int i = 0; i < 3; i++)
p[i]->Show();
cout << endl;
//cout << p << endl;
delete [] p;
return 0;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/11118.html
標籤:C++ 語言
上一篇:動態鏈表之插入結點的題目 補全插入函式 求助各位前輩QWQ
下一篇:如何在vc中更新控制元件內容
