Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>#include&lt;iostream&gt; #include&lt;string&gt; #include&lt;stdlib.h&gt; #include&lt;conio.h&gt; #include&lt;fstream&gt; #include&lt;string.h&gt; using namespace std; class Date { protected: int Day; int month; int year; public: Date() { this-&gt;Day=01; this-&gt; month=01; this-&gt; year=1990; } Date(int _day,int _month,int _year) {this-&gt; Day=_day ; this-&gt; month=_month; this-&gt; year=_year; } void display() { cout&lt;&lt;" Day/month/year :"&lt;&lt;Day&lt;&lt;"/"&lt;&lt;month&lt;&lt;"/"&lt;&lt;year&lt;&lt;endl; } }; class Login { protected: string UserName; char password[6]; public: Login() { this-&gt;UserName="User"; this-&gt; password[6]='1','2','3','4'; } Login (string user,char pass[6]) { this-&gt;UserName=user; this-&gt;password[6]=pass[6]; } void setUser(string a) { this-&gt;UserName=a; } void setPass(char c[6]) { this-&gt;password[6]=c[6]; } string getuser() { return this-&gt;UserName; } char getPass() { return this-&gt;password[6]; } }; class customer { protected: string Name; string Address; int age; int customer_no; Date DOfReg ; Date DOfBirth ; string contact_no; Login A ; friend class Admin; public: ofstream f; customer() { age=customer_no=0; } customer (string _Name ,string _Address,int _age,int _customerNo,Date DOB,Date DOR,string contactNo,Login a) { this-&gt; Name=_Name; this-&gt; Address=_Address; this-&gt; age=_age; this-&gt; customer_no=_customerNo; this-&gt; DOfReg= DOR ; this-&gt; DOfBirth= DOB ; this-&gt; contact_no = contactNo; this-&gt; A=a; f.open("person.dat",ios::in|ios::out|ios::app); f.write(reinterpret_cast&lt;char*&gt;(this),sizeof (*this)); f.close(); } void setName(string name) { this-&gt;Name=name;} void SetAddress( string add) { this-&gt;Address=add;} void setAge(int Age) { this-&gt;age=Age;} void SetCutomer(int no) {this-&gt;customer_no=no;} void setDOR(Date dor) {this-&gt;DOfReg=dor;} void setDOb(Date dob) { this-&gt; DOfBirth=dob;} void setContact(string contact) { this-&gt; contact_no=contact;} void setLogin(Login ID) { this-&gt; A=ID;} virtual void passchange(Login ID) {} virtual bool checkID(Login ) { return 0; } virtual void Reg() { } virtual void updateinfo() { } virtual void Show() { } virtual float paymentType() { return 0; } }; class Admin { protected: Login A; public: ofstream f; Admin() { string Y="Admin"; char z[5]={"4321"}; A.setUser(Y); A.setPass(z); cout&lt;&lt;z[5]; } Admin(Login ID) { A=ID; } bool checkID(Login ID) { if(A.getuser()==ID.getuser()&amp;&amp;A.getPass()==ID.getPass()) {return true; } else return false; } void Reg(customer&amp; a) { int c=0; cout&lt;&lt;"Enter Name :"&lt;&lt;endl; getline(cin,a.Name); cin.ignore(); cout&lt;&lt;"\nEnter Address :"&lt;&lt;endl; getline(cin,a.Address); cout&lt;&lt;"\nEnter Age :"&lt;&lt;endl; cin&gt;&gt;a.age; a.customer_no=c; int q,b,d; do{ cout&lt;&lt;"\nEnter Date Of Regestration "; cout&lt;&lt;"Format: DD/MM//YYYY"&lt;&lt;endl; cin&gt;&gt;q; cin&gt;&gt;b; cin&gt;&gt;d; if (q&lt;=31&amp;&amp;b&lt;=12&amp;&amp;d&lt;2014) { Date DOR(q,b,d); a.DOfReg = DOR ;break; } }while(q&gt;31&amp;&amp;b&gt;12&amp;&amp;d&gt;2013); do { cout&lt;&lt;"\nEnter Date Of Birth "; cout&lt;&lt;"Format: DD/MM//YYYY"&lt;&lt;endl; cin&gt;&gt;q;cin&gt;&gt;b;cin&gt;&gt;d; if (q&lt;=31&amp;&amp;b&lt;=12&amp;&amp;d&lt;2014) { Date DOB(q,b,d); a.DOfBirth= DOB ;break;} else {cout&lt;&lt;"\nWrong Format/Date :"&lt;&lt;endl;} }while(q&gt;31&amp;&amp;b&gt;12&amp;&amp;d&gt;2013); cout&lt;&lt;"\nEnter Your Contact No. :"; cout&lt;&lt;"Format: 0322-1234567 "&lt;&lt;endl; getline(cin,a.contact_no); cin.ignore(); c++; f.open("person.dat",ios::in|ios::out|ios::app); f.write(reinterpret_cast&lt;char*&gt;(this),sizeof (*this)); f.close(); } }; class PTCL : public customer { protected: public: fstream f; void Reg( ) { int c=0; cin.clear(); cin.ignore(); cout&lt;&lt;"\nEnter Name :"&lt;&lt;endl; getline(cin,Name); cin.ignore(); cout&lt;&lt;"\nEnter Address :"&lt;&lt;endl; getline(cin,Address);cin.ignore(); cout&lt;&lt;"\nEnter Age :"&lt;&lt;endl; cin&gt;&gt;age; customer_no=c; int a; int b; int d; //do{ cout&lt;&lt;"\nEnter Date Of Regestration "; cout&lt;&lt;"Format: DD/MM//YYYY"&lt;&lt;endl; cin&gt;&gt;a;cin&gt;&gt;b;cin&gt;&gt;d; // if (a&lt;=31&amp;&amp;b&lt;=12&amp;&amp;d&lt;2014) Date DOR(a,b,d); DOfReg = DOR; //break; //else {cout&lt;&lt;"\nWrong Format/Date :"&lt;&lt;endl;} // }while(a&gt;31&amp;&amp;b&gt;12&amp;&amp;d&gt;2013); // do // { // cout&lt;&lt;"\nEnter Date Of Birth "; cout&lt;&lt;"Format: DD/MM//YYYY"&lt;&lt;endl; // cin&gt;&gt;a;cin&gt;&gt;b;cin&gt;&gt;d; // if (a&lt;=31&amp;&amp;b&lt;=12&amp;&amp;d&lt;2014) // { //Date DOB(a,b,d); //DOfBirth= DOB ;//break; // } // else {cout&lt;&lt;"\nWrong Format/Date :"&lt;&lt;endl;} // }while(a&gt;31&amp;&amp;b&gt;12&amp;&amp;d&gt;2013); cin.clear();cin.ignore(); cout&lt;&lt;"\nEnter Your Contact No. :"; cout&lt;&lt;"Format: 0322-1234567 "&lt;&lt;endl; getline(cin,contact_no);cin.ignore(); c++; f.open("person.dat",ios::in|ios::out|ios::app); f.write(reinterpret_cast&lt;char*&gt;(this),sizeof (*this)); f.close(); } void passchange(Login ID) { cout&lt;&lt;"Enter New UserName :"&lt;&lt;endl; string User; getline(cin,User); A.setUser(User); char c[5]; cout&lt;&lt;"Enter New Password Of 4 letters"&lt;&lt;endl;; cin&gt;&gt;c[5]; A.setPass(c); f.open("person.dat",ios::in|ios::out|ios::app); f.write(reinterpret_cast&lt;char*&gt;(this),sizeof (*this)); f.close(); } bool checkID(Login ID) { if(A.getuser()==ID.getuser()&amp;&amp;A.getPass()==ID.getPass()) {return true; } else return false; } void updateinfo( ) { int x=0; cout &lt;&lt;"Which Info You Want to Update"&lt;&lt;endl; cout&lt;&lt;"1. Name :" &lt;&lt; Name&lt;&lt;endl; cout&lt;&lt;"2. Address :"&lt;&lt; Address&lt;&lt;endl; cout&lt;&lt;"3. Age :"&lt;&lt; age&lt;&lt;endl; cout&lt;&lt;"4. Date Of Birth :"; DOfBirth.display(); cout&lt;&lt;endl; cout&lt;&lt;"5. Contact No :"&lt;&lt;contact_no&lt;&lt;endl; cout&lt;&lt;endl; char choice; do { cout&lt;&lt;"choice :"&lt;&lt;endl; cin&gt;&gt;x; if (x==1) { cout&lt;&lt;"Enter New Name "&lt;&lt;endl; getline(cin,Name); f.open("person.dat",ios::in|ios::out|ios::app); f.write(reinterpret_cast&lt;char*&gt;(this),sizeof (*this)); f.close(); } else if (x==2) { cout&lt;&lt;"Enter New Address "&lt;&lt;endl; getline(cin,Address); f.open("person.dat",ios::in|ios::out|ios::app); f.write(reinterpret_cast&lt;char*&gt;(this),sizeof (*this)); f.close(); } else if(x==3) { cout&lt;&lt;"Update Your Age :"&lt;&lt;endl; cin&gt;&gt;age; f.open("person.dat",ios::in|ios::out|ios::app); f.write(reinterpret_cast&lt;char*&gt;(this),sizeof (*this)); f.close(); } else if(x==4) { cout&lt;&lt;"Update Your Birth info:"&lt;&lt;endl; int a,b,c; cin&gt;&gt;a;cin&gt;&gt;b;cin&gt;&gt;c; Date dOb(a,b,c); setDOb( dOb); f.open("person.dat",ios::in|ios::out|ios::app); f.write(reinterpret_cast&lt;char*&gt;(this),sizeof (*this)); f.close(); } else if(x==5) { cout&lt;&lt;"Update Your Contact No: "&lt;&lt;endl; cin&gt;&gt;contact_no; f.open("person.dat",ios::in|ios::out|ios::app); f.write(reinterpret_cast&lt;char*&gt;(this),sizeof (*this)); f.close(); } else { cout&lt;&lt;"Wrong input "&lt;&lt;endl; } cout&lt;&lt;"Do Yo Want to Update More (Y/N):"&lt;&lt;endl; cin&gt;&gt;choice; }while(choice=='N'); cout&lt;&lt;"Information Updated !! "&lt;&lt;endl; } void Show() { cout&lt;&lt;"1. Name :" &lt;&lt; Name&lt;&lt;endl; cout&lt;&lt;"2. Address :"&lt;&lt; Address&lt;&lt;endl; cout&lt;&lt;"3. Age :"&lt;&lt; age&lt;&lt;endl; cout&lt;&lt;"4. Date Of Birth :"; DOfBirth.display(); cout&lt;&lt;endl; cout&lt;&lt;"5. Contact No :"&lt;&lt;contact_no&lt;&lt;endl; cout&lt;&lt;"6. date of registration : "; DOfReg.display();cout&lt;&lt;endl; cout&lt;&lt;"7. customer no. : "&lt;&lt;customer_no&lt;&lt;endl; f.open("person.dat",ios::in|ios::out|ios::app); ifstream f1; f1.read(reinterpret_cast&lt;char*&gt;(this),sizeof (*this)); } }; class dell : public customer { protected: string country; public: fstream f; dell() { country="USA"; f.open("person.dat",ios::in|ios::out|ios::app); f.write(reinterpret_cast&lt;char*&gt;(this),sizeof (*this)); f.close(); } dell(string _Name ,string _Address,int _age,int _customerNo,Date DOB,Date DOR,string contactNo,string count) { Name=_Name; Address=_Address; age=_age; customer_no=_customerNo; DOfReg= DOR ; DOfBirth= DOB ; contact_no = contactNo; country=count; f.open("person.dat",ios::in|ios::out|ios::app); f.write(reinterpret_cast&lt;char*&gt;(this),sizeof (*this)); f.close(); } bool checkID(Login ID) { if(A.getuser()==ID.getuser()&amp;&amp;A.getPass()==ID.getPass()) {return true; } else return false; } void Reg() { string uName; int c=0;cin.ignore(); cout&lt;&lt;"Enter Name :"&lt;&lt;endl; getline(cin,Name); cin.ignore(); cout&lt;&lt;"\nEnter Address :"&lt;&lt;endl; getline(cin,Address); cout&lt;&lt;"\nEnter Age :"&lt;&lt;endl; cin&gt;&gt;age; customer_no=c; int a,b,d; do{ cout&lt;&lt;"\nEnter Date Of Regestration "; cout&lt;&lt;"Format: DD/MM//YYYY"&lt;&lt;endl; cin&gt;&gt;a;cin&gt;&gt;b;cin&gt;&gt;d; if (a&lt;=31&amp;&amp;b&lt;=12&amp;&amp;d&lt;2014) { Date DOR(a,b,d); DOfReg = DOR ;break; break; } }while(a&lt;=31&amp;&amp;b&lt;=12&amp;&amp;d&lt;2014); cin.clear(); do { cout&lt;&lt;"\nEnter Date Of Birth "; cout&lt;&lt;"Format: DD/MM//YYYY"&lt;&lt;endl; cin&gt;&gt;a;cin&gt;&gt;b;cin&gt;&gt;d; if (a&lt;=31&amp;&amp;b&lt;=12&amp;&amp;d&lt;2014) { Date DOB(a,b,d); DOfBirth= DOB ; break;} else {cout&lt;&lt;"\nWrong Format/Date :"&lt;&lt;endl;} }while(a&lt;=31&amp;&amp;b&lt;=12&amp;&amp;d&lt;2014); cin.clear(); cin.ignore(); cout&lt;&lt;"\nEnter Your Contact No. :"; cout&lt;&lt;"Format: 0322-1234567 "&lt;&lt;endl; getline(cin,contact_no); cin.clear(); cin.ignore(); cout&lt;&lt;"Create user Name "&lt;&lt;endl; getline(cin,uName);cin.clear(); cin.ignore(); char p[6]; cout&lt;&lt;"Create PassWord "&lt;&lt;endl; ///// hERE is The Eror " stack around P was corrupted even if I Input only 1 digit ! cin&gt;&gt;p[6]; A.setPass(p); A.setUser(uName); c++; f.open("person.dat",ios::in|ios::out|ios::app); f.write(reinterpret_cast&lt;char*&gt;(this),sizeof (*this)); f.close(); } void updateinfo( ) { int x=0; cout &lt;&lt;"Which Info You Want to Update"&lt;&lt;endl; cout&lt;&lt;"1. Name :" &lt;&lt; Name&lt;&lt;endl; cout&lt;&lt;"2. Address :"&lt;&lt; Address&lt;&lt;endl; cout&lt;&lt;"3. Age :"&lt;&lt; age&lt;&lt;endl; cout&lt;&lt;"4. Date Of Birth :"; DOfBirth.display(); cout&lt;&lt;endl; cout&lt;&lt;"5. Contact No :"&lt;&lt;contact_no&lt;&lt;endl; cout&lt;&lt;"6. country : "&lt;&lt;country; cout&lt;&lt;endl; char choice; do { cout&lt;&lt;"choice :"&lt;&lt;endl; cin&gt;&gt;x; if (x==1) { cout&lt;&lt;"Enter New Name "&lt;&lt;endl; getline(cin,Name);cin.ignore(); f.open("person.dat",ios::in|ios::out|ios::app); f.write(reinterpret_cast&lt;char*&gt;(this),sizeof (*this)); f.close(); } else if (x==2) { cout&lt;&lt;"Enter New Address "&lt;&lt;endl; getline(cin,Address); cin.ignore(); f.open("person.dat",ios::in|ios::out|ios::app); f.write(reinterpret_cast&lt;char*&gt;(this),sizeof (*this)); f.close(); } else if(x==3) { cout&lt;&lt;"Update Your Age :"&lt;&lt;endl; cin&gt;&gt;age; f.open("person.dat",ios::in|ios::out|ios::app); f.write(reinterpret_cast&lt;char*&gt;(this),sizeof (*this)); f.close(); } else if(x==4) { cout&lt;&lt;"Update Your Birth info:"&lt;&lt;endl; int a,b,c; cin&gt;&gt;a;cin&gt;&gt;b;cin&gt;&gt;c; Date dOb(a,b,c); setDOb( dOb); f.open("person.dat",ios::in|ios::out|ios::app); f.write(reinterpret_cast&lt;char*&gt;(this),sizeof (*this)); f.close(); } else if(x==5) { cout&lt;&lt;"Update Your Contact No: "&lt;&lt;endl; cin&gt;&gt;contact_no; f.open("person.dat",ios::in|ios::out|ios::app); f.write(reinterpret_cast&lt;char*&gt;(this),sizeof (*this)); f.close(); } else if(x==6) { cout&lt;&lt;"Update Country Name : "&lt;&lt;endl; cin&gt;&gt;country; f.open("person.dat",ios::in|ios::out|ios::app); f.write(reinterpret_cast&lt;char*&gt;(this),sizeof (this)); f.close(); } else { cout&lt;&lt;"Wrong input "&lt;&lt;endl; } cout&lt;&lt;"Do Yo Want to Update again (Y/N):"&lt;&lt;endl; cin&gt;&gt;choice; }while(choice=='N'); cout&lt;&lt;"Information Updated !! "&lt;&lt;endl; } void Show() { cout&lt;&lt;"1. Name :" &lt;&lt; Name&lt;&lt;endl; cout&lt;&lt;"2. Address :"&lt;&lt; Address&lt;&lt;endl; cout&lt;&lt;"3. Age :"&lt;&lt; age&lt;&lt;endl; cout&lt;&lt;"4. Date Of Birth :"; DOfBirth.display(); cout&lt;&lt;endl; cout&lt;&lt;"5. Contact No :"&lt;&lt;contact_no&lt;&lt;endl; cout&lt;&lt;"6. date of registration : "; DOfReg.display();cout&lt;&lt;endl; cout&lt;&lt;"7. customer no. : "&lt;&lt;customer_no&lt;&lt;endl; cout&lt;&lt;"8. country : "&lt;&lt;country&lt;&lt;endl; ifstream f1; f1.open("person.dat",ios::in|ios::out|ios::app); f1.read(reinterpret_cast&lt;char*&gt;(this),sizeof (*this)); } }; void main() { customer *ptr[100]; string Name; string Address; int age; int customer_no; Date DOfReg; Date dofbirth; string contact_no; string country; int c; int count; char choice; string User; char Pin[6]; int p; for (int i=0;i&lt;100;i++) { cout&lt;&lt;"\n\n********======================*******\n\n"&lt;&lt;endl; cout&lt;&lt;" \n Welcome To Customer Services "&lt;&lt;endl; cout&lt;&lt;"\n1. Login for Registerd Member (PTCL/UFONE) "&lt;&lt;endl; cout &lt;&lt;"\n2. SignUp for Regestration (PTCL/UFONE ) "&lt;&lt;endl; cout&lt;&lt;"\n3. Search for Regesterd Memebers (Only for Admin) "&lt;&lt;endl; cout&lt;&lt;"\Choice :"&lt;&lt;endl; cin&gt;&gt;c; if (c==1) { cin.ignore(); cout&lt;&lt;"\n Enter User Name "&lt;&lt;endl; getline(cin,User); //std::cin.ignore(); cout&lt;&lt;"\nEnter Pin of no More than 4 characters"&lt;&lt;endl; for (int i=0;i&lt;20;i++) { Pin[i]=getch(); if (Pin[i]==13) { Pin[i]=0; break; } if (Pin[i]!=8) cout &lt;&lt; "*"; } Login ID(User,Pin); //PassWord Sent Here; if (ptr[i]-&gt;checkID(ID)) //Password match Check { cout&lt;&lt;"\n Welcome "&lt;&lt;endl; cout&lt;&lt;"\n1. for Update Info "&lt;&lt;endl; cout&lt;&lt;"\n2. for View Info "&lt;&lt;endl; cout&lt;&lt;"\n3. for Pass change"&lt;&lt;endl; cout&lt;&lt;"\n Choice "&lt;&lt;endl; cin&gt;&gt;count; if (count==1) { ptr[i]-&gt;updateinfo(); } else if(count==2) { ptr[i]-&gt;Show(); } else if(count==3) { ptr[i]-&gt;passchange(ID); } } //Check ID if bracket else { cout&lt;&lt;"\nUserName Or PassWord is Invalid: "&lt;&lt;endl;} }//c==1 bracket else if (c==2) { cout&lt;&lt;"\nWhoose Customer You Want To be Dell(D) / PTCL(P) "&lt;&lt;endl; cin&gt;&gt;choice; if (choice=='D'||'d') { ptr[i] = new dell; ptr[i]-&gt;Reg(); } else if (choice=='P'||'p') { ptr[i]=new PTCL; ptr[i]-&gt;Reg(); } else {cout&lt;&lt;"\nWrong Choice" &lt;&lt;endl; } } } getch(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload