ClassMoney

#include
using namespace std;
class student
{
private:
static float m_Classmoney;
public:
int Student(){}
~student(){}
void InitStudent(char name[]);
void ExpendMoney(float money);
static void ShowMoney();
};
float student::m_Classmoney = 1000;
void student::InitStudent(char name[])
{
for (int i = 0; i < 2; i++)
{
cout << name[i] << endl;
}
}
void student::ExpendMoney(float money)
{
m_Classmoney = m_Classmoney - money;
}
void student::ShowMoney()
{
cout <<“班费还剩余:”<< m_Classmoney << endl;
}
int main()
{
student stu;
stu.ExpendMoney(50);
stu.ShowMoney();
stu.ExpendMoney(98.5);
stu.ShowMoney();
stu.ExpendMoney(500.53);
stu.ShowMoney();
return 0;
}

你可能感兴趣的:(笔记)