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

📄 unit.cpp

📁 浙江工业大学C++数据结构课程设计的练习作品 有一定的难度 有英文原题说明(老外授课)大家可以先看题自己做再参考我的程序
💻 CPP
字号:
#include <iostream.h>
#include <string.h>
#include <assert.h>
#include "unit.h"
#include "list.h"

Unit::Unit(char* _name,char* _code){
	name = new char[strlen(_name)+1];
	assert(name!=0);
	strcpy(name,_name);
	cout<<"name="<<name<<endl;
	code = new char[6];
	assert(code!=0);
	strcpy(code,_code);
	cout<<"code="<<code<<endl;
}

Unit::Unit(){
	name = "";
	code = "";
}

Unit::~Unit(){
	//delete [] name;
	//delete [] code;
	
}

void Unit::addStudent(Student s){
	h.insert_at_front(s);
}

void Unit::setName(char* _name){
	name = new char[strlen(_name)+1];
	assert(name!=0);
	strcpy(name,_name);
}

void Unit::setCode(char* _code){
	code = new char[6];
	assert(code!=0);
	strcpy(code,_code);
}

char* Unit::getName() const{
	char* tempName = new char[strlen(name)+1];
	assert(tempName!=0);
	strcpy(tempName,name);
	return tempName;
}

char* Unit::getCode() const{
	char* tempCode = new char[strlen(code)+1];
	assert(tempCode!=0);
	strcpy(tempCode,code);
	return tempCode;
}

/*void Unit::dispList() const{
	node* current;
	current = h.first;
	while(current!=NULL){
		cout<<current.getName()<<','<<current.getCode();
		cout<<endl;
		current = current.next;
	}
}*/

/*int Unit::getCount(){
	int count = 0;
	node* current;
	current = h.first;
	while(current!=NULL){
		count++;
		current = current.next;
	}
	return --count;
}*/

⌨️ 快捷键说明

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