头文件 Record.h
#ifndef HEADER_RECORD
#define HEADER_RECORD
#include<iostream>
#include<string>
using namespace std;
class Record
{
private:
int number;
string userName;
string passWord;
double balance;
int flag;
public:
Record();
void set_number(int number);
void set_userName(string userName);
void set_passWord(string passWord);
void set_balance(double balance);
void set_flag(int flag);
int get_number();
string get_userName();
string get_passWord();
double get_balance();
int get_flag();
void display_Record();
};
#endif
源文件Record.cpp
#include"Record.h"
#include<iostream>
using namespace std;
Record::Record()
{
this -> number = 0;
this -> userName = "";
this -> passWord = "";
this -> balance = 0;
this -> flag = -1;
}
void Record::set_number(int number)
{
this -> number = number;
}
void Record::set_userName(string userName)
{
this -> userName = userName;
}
void Record::set_passWord(string passWord)
{
this -> passWord = passWord;
}
void Record::set_balance(double balance)
{
this -> balance = balance;
}
void Record::set_flag(int flag)
{
this -> flag = flag;
}
int Record::get_number()
{
return this -> number;
}
string Record::get_userName()
{
return this -> userName;
}
string Record::get_passWord()
{
return this -> passWord;
}
double Record::get_balance()
{
return this -> balance;
}
int Record::get_flag()
{
return this -> flag;
}
void Record::display_Record()
{
cout << "Print Record Elements......" << endl;
cout << "Number : " << this -> number << endl;
cout << "UserName : " << this->userName << endl;
cout << "PassWord : " << this -> passWord << endl;
cout << "Balance : " << this -> balance << endl;
cout << "Flag : " << this -> flag << endl;
cout << "End of Record......" << endl;
}
测试文件 TestRecord.cpp
#include"Record.h"
int main()
{
Record *record = new Record();
record -> display_Record();
record ->set_number(10001);
record ->set_userName("zhangsan");
record ->set_passWord("123456");
record ->set_balance(10000);
record ->set_flag(1);
record ->display_Record();
return 0;
}
上机感言:这是暑假里的第一堂课,整体上感觉还不错,这样一来到了正式开学就能金人学习状态了,不用再花很长时间来调整了