您的当前位置:首页正文

include

来源:好兔宠物网
#include \"stdafx.h\" #include using std::cin; using std::cout; using std::endl; #include using std::string; class Student {

private:

int no; //*** int number; string name; int c; int os; public:

static int total; //*** Student();

Student(int,string);

Student(int,string, int, int); Student(Student &);

void setNumber(int); int getNumber();

void setName(string); string getName(); void setC(int); int getC();

void setOs(int); int getOs();

void setStudent(int n,string,int,int); void ShowStudent(); };

Student::Student() {

total++; //*** no=total; //*** number=0; name=\"\"; c=0; os=0; }

Student::Student(int n,string s) {

total++; //*** no=total; //*** number=n; name=s; c=0; os=0; }

Student::Student(int n,string s,int bc,int bos) {

total++; //*** no=total; //*** number=n; name=s; c=bc; os=bos; }

Student::Student(Student &s) {

total++; //*** no=total; //*** number=s.number; name=s.name;

c=s.c; os=s.os; }

void Student::ShowStudent() {

cout<void Student::setNumber(int n) {

number=n; }

int Student::getNumber() {

return number; }

void Student::setName(string s) {

name=s; }

string Student::getName() {

return name; }

void Student::setC(int bc) {

c=bc; }

int Student::getC() {

return c; }

void Student::setOs(int bos) {

os=bos; }

int Student::getOs() {

return os; }

void Student::setStudent(int bc,int bos) {

number=n;

n,string bs,int name=bs; c=bc; os=bos; }

class Table {

private:

int table_number;

int size; //*** Student *sp; public:

Table(int,int); //*** 表号,行数 // ~Table();

void append(); void change(); void showTable(); void operate(); int getNumber(); };

Table::Table(int tn, int hs)

{

table_number=tn;

size=hs;

sp=new Student[size]; }

//Table::~Table() //{

// delete [] sp; //}

void Table::showTable() {

int i;

cout<<\".........showTable............\"<(*(sp+i)).ShowStudent(); }

void Table::append() {

int i;

int number_buf; string name_buf; int c_buf; int os_buf;

for( i=0; i<20; i++) {

if ( (*(sp+i)).getNumber()==0) break; }

cout<<\".....append.........\"<>number_buf; cout<<\"name:\"; cin>>name_buf; cout<<\"c:\" ; cin>>c_buf; cout<<\"os:\" ; cin>>os_buf;

(*(sp+i)).setStudent(number_buf,name_buf,c_buf,os_buf); }

void Table::change() {

int i;

int number_buf;

string name_buf; int c_buf; int os_buf;

cout<<\"....change...............\"<>number_buf; for( i=0; i<20; i++) {

if ((*(sp+i)).getNumber()==number_buf) break; }

cout<<\"number:\"; cin>>number_buf; cout<<\"name:\"; cin>>name_buf; cout<<\"c:\" ; cin>>c_buf; cout<<\"os:\" ; cin>>os_buf;

(*(sp+i)).setStudent(number_buf,name_buf,c_buf,os_buf); }

void Table::operate() {

char operate_choice;

do {

cout<<\".......Table\"<cout<<\"a: append\"<cout<<\"---------------------------\"<>operate_choice;

switch(operate_choice) {

case 'a': append();break; case 'c': change();break; case 's': showTable();break; }

}while(operate_choice!='q');

}

int Table::getNumber() {

return table_number; }

int Student::total=0;

int main(int argc, char* argv[]) {

int table_number_buffer; Student::total=0; Table t1(1,11); Student::total=0; Table t2(2,12); Student::total=0; Table t3(3,13);

do {

cout<<\".......main.............\"<cout<<\"Enter table_number(1,2,3, 0:quit):\";

cin>>table_number_buffer;

if( t1.getNumber()==table_number_buffer ) t1.operate();

if( t2.getNumber()==table_number_buffer ) t2.operate();

if( t3.getNumber()==table_number_buffer ) t3.operate();

}while( table_number_buffer!=0 );

return 0; }

因篇幅问题不能全部显示,请点此查看更多更全内容