class Contact {private: string name; string tel; string postcode;public: Contact(string name, string tel, string postcode) { this->name = name; this->tel = tel; this->postcode = postcode; } string getName() { return name; } string getTel() { return tel; } string getPostcode() { return postcode; } void setName(string name) { this->name = name; } void setTel(string tel) { this->tel = tel; } void setPostcode(string postcode) { this->postcode = postcode; } void display() { cout << "Name: " << name << endl; cout << "Tel: " << tel << endl; cout << "Postcode: " << postcode << endl; }};
时间: 2023-05-20 21:03:46 浏览: 67
dutch-postcode-regex:匹配荷兰邮政编码的正则表达式
这是一个 Contact 类的定义,它包含了三个私有成员变量 name、tel 和 postcode,以及一些公有成员函数,包括构造函数、获取成员变量值的函数和设置成员变量值的函数,还有一个 display 函数用于打印成员变量的值。
阅读全文