#include<iostream>
#include<stdlib.h>
#include<string>
#include"Teacher.h"
using namespace std;
int main()
{
Teacher t1;
Teacher t2("Tom",70);
Teacher t3("Merry");
cout<<t1.getName()<<" "<<t1.getAge()<<endl;
cout<<t2.getName()<<" "<<t2.getAge()<<endl;
cout<<t3.getName()<<" "<<t3.getAge()<<endl;
system("pause");
return 0;
}
#include"Teacher.h"
#include<iostream>
#include<stdlib.h>
using namespace std;
Teacher::Teacher()
{
m_strName="James";
m_iAge=15;
cout<<"Teacher()"<<endl;
}
Teacher::Teacher(string _name,int _age=35)
{
m_strName=_name;
m_iAge=_age;
cout<<"Teacher(string _name,int _age=)"<<endl;
}
void Teacher::setName(string _name)
{
m_strName=_name;
}
string Teacher::getName()
{
return m_strName;
}
void Teacher::setGender(string _gender)
{
m_strGender=_gender;
}
string Teacher::getGender()
{
return m_strGender;
}
void Teacher::setAge(int _age)
{
m_iAge=_age;
}
int Teacher::getAge()
{
return m_iAge;
}
void Teacher::teach()
{
cout<<"Class begins!"<<endl;
}
#include<string>
using namespace std;
class Teacher
{
public:
Teacher();
Teacher(string _name,int _age);
void setName(string _name);
string getName();
void setGender(string _gender);
string getGender();
void setAge(int _age);
int getAge();
void teach();
private:
string m_strName;//m_表示数据成员的意思
string m_strGender;
int m_iAge;
};