标签:clu private names str TE void col class stream
#include <iostream> #include <string> using namespace std; class teacher{ public: void setName(string _name); string getName(); void setGender(string _gender); string getGender(); void teach(); private: string strName; string strGender; }; void teacher::setName(string _name){ strName=_name; } string teacher::getName(){ return strName; } void teacher::setGender(string _gender){ strGender=_gender; } string teacher::getGender(){ return strGender; } void teacher::teach(){ cout << "上课" << endl; } int main() { teacher t; t.setName("A"); t.setGender("女"); cout << t.getName() + " " << t.getGender() << endl; t.teach(); return 0; }
标签:clu private names str TE void col class stream
原文地址:https://www.cnblogs.com/pjishu/p/9230987.html