#include#include using namespace std; class Contact { protected: string tenLienLac; string sdt; public: void Nhap(); void Xuat(); }; class ExConaect : public Contact{ private: string email; string ngaySinh; public: void NhapTT(); void XuatTT(); string CatPhanMoRong(); }; void Contact::Nhap() { cout << "nhap ten lien lac : "; getline(cin, tenLienLac); cout << "nhap thong std : "; getline(cin, sdt); } void Contact::Xuat() { cout << "ten lien lac : " << tenLienLac << endl; cout << "SDT : " << sdt << endl; } void ExConaect::NhapTT() { Nhap(); cout << "nhap email : "; getline(cin, email); cout << "ngay sinh : "; getline(cin, ngaySinh); } void ExConaect::XuatTT() { Xuat(); cout << "email : " << email << endl; cout << "ngay sinh : " << ngaySinh << endl << endl; } string ExConaect::CatPhanMoRong() { string tam = ""; for (int i = 0; i < email.length(); i++) { if (email[i] == '@') { return tam; } tam += email[i]; } } int main() { ExConaect ex; ex.NhapTT(); ex.XuatTT(); cout << "phan mo rong la : " << ex.CatPhanMoRong(); system("pause"); return 0; }
0 nhận xét:
Đăng nhận xét