25 lines
503 B
C++
25 lines
503 B
C++
|
// 1. 2. 创建一个名为 BankAccount 的类,具有成员变量 accountNumber 和 balance,以及成员函数 void deposit(double amount) 和 void withdraw(double amount) ,用于存款和取款操作。
|
|||
|
#include <iostream>
|
|||
|
|
|||
|
using namespace std;
|
|||
|
|
|||
|
class BankAccount
|
|||
|
{
|
|||
|
public:
|
|||
|
long accountNumber, balance;
|
|||
|
void deposit(double amount)
|
|||
|
{
|
|||
|
this->balance += amount;
|
|||
|
}
|
|||
|
void withdraw(double amount)
|
|||
|
{
|
|||
|
this->balance -= amount;
|
|||
|
}
|
|||
|
};
|
|||
|
|
|||
|
int main()
|
|||
|
{
|
|||
|
|
|||
|
return 0;
|
|||
|
}
|