func.cpp

来自「一、教学目的: 能理解C++中运算符重载的需要性」· C++ 代码 · 共 175 行

CPP
175
字号
void add()
{
	int choose;
	unsigned accnum;
	cout<<endl<<endl<<endl<<endl<<endl
	    <<"                       "
	    <<"Please choose the type"
		<<endl<<endl<<endl
		<<"               1.Savings"<<endl<<endl
		<<"               2.Cheching"<<endl<<endl
		<<endl<<endl<<endl<<endl<<endl<<endl;
	cin>>choose;
	switch(choose)
	{
		case 1:
			cout<<"      Input Savings Account number";
			cin >>accnum;
			new Savings(accnum);
			break;
		case 2:
			cout<<"      Input Checking Account number";
			cin >>accnum;
			new Checking(accnum);
	}
}
void deposit()
{
	int choose;
	unsigned accnum;
	float amount;
	static Account* p;
	cout<<endl<<endl<<endl<<endl<<endl
	    <<"                       "
	    <<"Please choose the type"
		<<endl<<endl<<endl
		<<"               1.Savings"<<endl<<endl
		<<"               2.Cheching"<<endl<<endl
		<<endl<<endl<<endl<<endl<<endl<<endl;
	cin>>choose;
	switch(choose)
	{
		case 1:
			cout<<"      Input Savings Account number";
			cin >>accnum;
			p=shead.First();
			while(p&&((*p).AccountNo()!=accnum))p=(*p).Next();
			if(!p)cout<<"No Found!";
            else 
			{
				cout<<"Input the amount:";
				cin>>amount;
				(*p).Deposit(amount);
			}
			break;
		case 2:
			cout<<"      Input Checking Account number";
			cin >>accnum;
			p=chead.First();
			while(p&&((*p).AccountNo()!=accnum))p=(*p).Next();
			if(!p)cout<<"No Found!";
            else 
			{
				cout<<"Input the amount:";
				cin>>amount;
				(*p).Deposit(amount);
			}
	}
}
void withdr()
{
	int choose;
	unsigned accnum;
	float amount;
	static Account* p;
	cout<<endl<<endl<<endl<<endl<<endl
	    <<"                       "
	    <<"Please choose the type"
		<<endl<<endl<<endl
		<<"               1.Savings"<<endl<<endl
		<<"               2.Cheching"<<endl<<endl
		<<endl<<endl<<endl<<endl<<endl<<endl;
	cin>>choose;
	switch(choose)
	{
		case 1:
			cout<<"      Input Savings Account number";
			cin >>accnum;
			p=shead.First();
			while(p&&((*p).AccountNo()!=accnum))p=(*p).Next();
			if(!p)cout<<"No Found!";
            else 
			{
				cout<<"Input the amount:";
				cin>>amount;
				(*p).Withdrawal(amount);
			}
			break;
		case 2:
			cout<<"      Input Checking Account number";
			cin >>accnum;
			p=chead.First();
			while(p&&((*p).AccountNo()!=accnum))p=(*p).Next();
			if(!p)cout<<"No Found!";
            else 
			{
				cout<<"Input the amount:";
				cin>>amount;
				(*p).Withdrawal(amount);
			}
	}
}
void del()
{
	int choose;
	unsigned accnum;
	static Account* p;
	cout<<endl<<endl<<endl<<endl<<endl
	    <<"                       "
	    <<"Please choose the type"
		<<endl<<endl<<endl
		<<"               1.Savings"<<endl<<endl
		<<"               2.Cheching"<<endl<<endl
		<<endl<<endl<<endl<<endl<<endl<<endl;
	cin>>choose;
	switch(choose)
	{
		case 1:
			cout<<"      Input Savings Account number";
			cin >>accnum;
			p=shead.First();
			while(p&&((*p).AccountNo()!=accnum))p=(*p).Next();
			if(!p)cout<<"No Found!";
            else  delete p;
			break;
		case 2:
			cout<<"      Input Checking Account number";
			cin >>accnum;
			p=chead.First();
			while(p&&((*p).AccountNo()!=accnum))p=(*p).Next();
			if(!p)cout<<"No Found!";
            else  delete p;
	}
}
void disp()
{
	int choose;
	unsigned accnum;
	static Account* p;
	cout<<endl<<endl<<endl<<endl<<endl
	    <<"                       "
	    <<"Please choose the type"
		<<endl<<endl<<endl
		<<"               1.Savings"<<endl<<endl
		<<"               2.Cheching"<<endl<<endl
		<<endl<<endl<<endl<<endl<<endl<<endl;
	cin>>choose;
	switch(choose)
	{
		case 1:
			cout<<"      Input Savings Account number";
			cin >>accnum;
			p=shead.First();
			while(p&&((*p).AccountNo()!=accnum))p=(*p).Next();
			if(!p)cout<<"No Found!";
            else  (*p).Display();
			break;
		case 2:
			cout<<"      Input Checking Account number";
			cin >>accnum;
			p=chead.First();
			while(p&&((*p).AccountNo()!=accnum))p=(*p).Next();
			if(!p)cout<<"No Found!";
            else  (*p).Display();
	}
}

⌨️ 快捷键说明

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