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

📄 func.cpp

📁 一、教学目的: 能理解C++中运算符重载的需要性
💻 CPP
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -