arrayofstud.cpp

来自「在进行C++培训时」· C++ 代码 · 共 37 行

CPP
37
字号
#include<iostream>
#include<string>
#include"arrayofstud.h"
using namespace std;
ArrayofStud::ArrayofStud(int l)
	{
		cout<<"call arrayofstud's constructor"<<this<<endl;
		length=l;
		sp=new Stud[length];
		
	}
	Stud &ArrayofStud::member(int index)
	{
		if(index<length)
		{
			return sp[index];
		}
		else
		{
			cout<<"index is too large"<<endl;
			exit(0);
		}
	}
	ArrayofStud::ArrayofStud(ArrayofStud &s)
	{
		length=s.length;
		sp=new Stud[length];
		for(int i=0;i<length;i++)
		{
			sp[i]=s.sp[i];
		}
	}
	ArrayofStud::~ArrayofStud()
	{
		cout<<"call arrayofstud's destructor"<<this<<endl;
		delete [] sp;
	}

⌨️ 快捷键说明

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