(1)user类的用法
#include<iostream> #include<string> #include <conio.h> #include <algorithm> using namespace std; class User{ public: User(string name,string email="",string passwd="111111" ):name(name),email(email),passwd(passwd){}; void emailcin(); //输入邮箱 void changePasswd(); void printInfo(); int checkemail(); //检查邮箱是否含有@ private: string name; string passwd; string email; }; //user类的定义 int main() { cout << "testing 1......" << endl; User user1("Leonard","178392qq.com"); user1.printInfo(); do{ int defact; defact=user1.checkemail(); if(defact) { cout<<"please enter your email again:"; user1.emailcin(); } else break; }while(1); //判断是否含@ user1.printInfo(); user1.changePasswd(); cout<<endl; user1.printInfo(); cout<<endl; cout << endl << "testing 2......" << endl ; User user2("Jonny","92197","xyz@hotmail.com"); user2.printInfo(); return 0; } void User::changePasswd(){ string past; char ch; int i=1,k; cout<<"please enter the past passwd:"; while(i++<=3){ for(k=1;k<=6;k++){ ch=getch(); cout<<"*"; past=past+ch; } if(past==passwd) break; else cout<<endl<<"please enter the past passwd:"; } if(i<=3){ cout<<endl<<"now please enter the new passwd:"; char a[7]; passwd='