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

📄 09_03.cpp

📁 一些C++的课件和实验源代码
💻 CPP
字号:
// 09_03.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <conio.h>
#include <iostream>
using namespace std;

class intArray{
protected:
	int	size;
	int* real;
public:
	intArray(int size){ 
		intArray::size = size;
		real = new int[size];
		cout << "intArray()." << endl;
	}
	virtual ~intArray(){ 
		if (real) delete []real;
		cout << "~intArray()." << endl;
	}
};

class complexArray: public intArray{
protected:
	int* virt;
public:
	complexArray(int size):intArray(size){ 
		virt = new int[size];
		cout << "complexArray()." << endl;
	}
       ~complexArray(){ 
		if (virt) delete virt;
		cout << "~complexArray()." << endl;
	}
};

int main(){
	complexArray* pc = new complexArray(10);
	delete pc;
	
	cout << endl;

	intArray* pi = new complexArray(10);
	delete pi;

	getch();
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -