📄 school.cpp
字号:
// school.cpp: implementation of the school class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "school.h"
#include <string.h>
#include <iostream.h>
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
// --------------------------------------------------------------------------
// class DataRec's implement
DataRec::DataRec()
{
name = NULL;
streetAddress = NULL;
city = NULL;
state = NULL;
zip = NULL;
}
DataRec::DataRec( char* n, char* st, char* cty, char* sta, char* zp )
{
name = StrSave(n);
streetAddress = StrSave(st);
city = StrSave(cty);
state = StrSave(sta);
zip = StrSave(zp);
}
DataRec::~DataRec()
{
delete name;
delete streetAddress;
delete city;
delete state;
delete zip;
}
void DataRec::Print()
{
cout << endl << endl << name << endl
<< streetAddress << endl
<< city << ", "
<< state << " "
<< zip;
}
char* DataRec::StrSave( char* s )
{
char* p;
p = new char[ strlen(s) + 1 ];
strcpy( p, s );
return p;
}
// --------------------------------------------------------------------------
// class Student's implement
void Student::Print()
{
DataRec::Print();
Disp();
}
void Student::Disp()
{
cout << "\nmajor: " << major;
cout << "\nId number: " << idNumber;
cout << "\nlevel: " << level;
}
// --------------------------------------------------------------------------
// class Staff's implement
void Staff::Print()
{
DataRec::Print();
Disp();
}
void Staff::Disp()
{
cout << "\nDepartment: " << dept;
cout << "\nhourly wage: " << hourlyWage;
}
// --------------------------------------------------------------------------
// class Professor's implement
void Professor::Print()
{
Staff::Print();
cout << "\nSalary: " << salary;
}
// --------------------------------------------------------------------------
// class StudentStaff's implement
void StudentStaff::Print()
{
DataRec::Print();
Student::Disp();
Staff::Disp();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -