#include #include using namespace std; class User { // Protected data members protected: int ID; char * Name; char * PassWord; char * Status; public: // Defaulr and overloaded constructors User(){ID = 0; Name = NULL; PassWord = NULL; Status = NULL;} User(int, char*, char*, char*); // Member function of User class void AddUser(); // Setter functions void set_ID(); void set_Name(); void set_PassWord(); // Getter funcitons int get_ID(); const char * get_Name() const; const char * get_PassWord() const; const char * get_Status() const; ~User(); }; User::User(int id, char * _name, char * pw, char * stat ){ //Overload constructor id = ID; Name = new char[strlen(_name)+1]; strcpy(Name,_name); PassWord = new char[strlen(pw)+1]; strcpy(PassWord,pw); Status = new char[strlen(stat)+1]; strcpy(Status,stat); } void User::AddUser() { int choice; cout << "\n\nPlease select any option:\n" << endl; cout <<"1-Member User>" << endl; cout <<"2-Admin User>" << endl; cin >> choice; if (choice == 1){ set_ID(); set_Name(); set_PassWord(); char stat[15]="Member"; Status = new char[strlen(stat)+1]; strcpy(Status,stat); } else if (choice == 2){ set_ID(); set_Name(); set_PassWord(); char stat[15]="Administrator"; Status = new char[strlen(stat)+1]; strcpy(Status,stat); } else cout << "Illegal choice!"; } // Implementation of set_ID() method void User::set_ID(){ cout<<"\nEnter User ID:"; cin >>ID; } // Implementation of set_Name() method void User::set_Name(){ char name[50]; cout << "\nEnter name:"; cin >> name; Name = new char[strlen(name)+1]; strcpy(Name,name); } // Implementation of set_PassWord() method void User::set_PassWord(){ char pswd[10]; cout<<"\nEnter User PassWord:"; cin >> pswd; PassWord = new char[strlen(pswd)+1]; strcpy(PassWord,pswd); } // Implementation of get_ID() method, int User::get_ID(){ if( ID != 0){ return ID; } } // Implementation of get_Name() method const char * User::get_Name() const{ if(Name != NULL){ return Name; } } // Implementation of get_PassWord() method const char * User::get_PassWord() const{ if(PassWord != NULL){ return PassWord; } } // Implementation of get_Status() method const char * User::get_Status() const{ if(Status != NULL){ return Status; } } User::~User(){// destructor of User class delete []Name; delete []PassWord; delete []Status; cout << "\nThis User has been deleted successfully:"; }; class Cards{ // Protected data members private: int id; char * name; char * message; public: Cards(){id = 0; name = NULL; message = NULL;} //default Constructor Cards(int, char*, char*); // Overloaded constructor // Member function of Cards class void AddCards(); // Setter functions void set_ID(); void set_Name(); void set_Message(); // Getter funcitons int get_ID(); const char * get_Name() const; const char * get_Message() const; // Destructor ~Cards(); }; Cards::Cards(int _id, char * _name, char * _message){ //Overload constructor id = _id; name = new char[strlen(_name)+1]; strcpy(name,_name); message = new char[strlen(_message)+1]; strcpy(message,_message); } void Cards::AddCards() { int choice; cout << "\n\nPlease select any one option:\n" << endl; cout <<"1-Birth Cards>" << endl; cout <<"2-Marriage Cards>" << endl; cout <<"3-Frinedship Cards>" << endl; cout <<"4-Baraat Cards>" << endl; cout <<"5-Walima Cards>" << endl; cout <<"6-Mehindi Cards>" << endl; cin >> choice; if (choice > 0 && choice <=6){ set_ID(); set_Name(); set_Message(); } else cout << "Illegal choice"; } // Implementation of set_ID() method void Cards::set_ID(){ cout<<"\nEnter Card ID:"; cin >>id; } // Implementation of set_Name() method void Cards::set_Name(){ char Name[50]; cout<<"\nEnter name:"; cin >> Name; name = new char[strlen(Name)+1]; strcpy(name,Name); } // Implementation of set_Message() method void Cards::set_Message(){ char Message[200]; cout<<"\nEnter Message for the receiver:"<< "\n"; cin >> Message; // .getline(Message,200); message = new char[strlen(Message)+1]; strcpy(message,Message); } // Implementation of get_ID() method, int Cards::get_ID(){ if(id != 0){ return id; } } // Implementation of get_Name() method const char * Cards::get_Name() const{ if(name != NULL){ return name; } } // Implementation of get_Message() method const char * Cards::get_Message() const{ if(message != NULL){ return message; } } Cards::~Cards(){// destructor Cards class delete []name; delete []message; cout << "\nThis card has been deleted successfully:"; } int main(){ int id; char selection; int option; User u; // object User class Cards c; // object Cards class cout << "\t\tPress 'u' for calling add method of User class:" <> selection; if (selection == 'u'){ while (option != 3) { cout << "\n\nPlease select any one option:\n" << endl; cout <<"Press 1 for User>" << endl; cout <<"Press 2 for viewing User's details>" << endl; cout <<"Press 3 for deleting User>" << endl; cin >> option; switch(option) { case 1: system("cls"); u.AddUser(); break; case 2: system("cls"); cout << "\nUser ID:\t" << u.get_ID() << endl; cout << "\nUser Name:\t" << u.get_Name() << endl; cout << "\nStatus:\t\t" << u.get_Status()<< endl; break; case 3: int id; cout << "Enter User ID:"; cin >> id; if(u.get_ID()!=id){ cout << "User not found!\n"; system("pause"); exit(0); } else { cout << "\nDo you want to delete this User?"; cout << "\nUser ID:" << u.get_ID() << "\tUser Name:" << u.get_Name(); cout << "\n\nPress 'y'or 'Y' to confrim:"; cin >> selection; } if (selection == 'y'||selection == 'Y') u.~User(); break; } } cout << endl << endl << endl; } else if (selection == 'c'){ while (option != 3) { cout <<"\n\nPlease select any one option:\n" << endl; cout <<"Press 1 for Cards>" << endl; cout <<"Press 2 for viewing cards>" << endl; cout <<"Press 3 for deleting cards>" << endl; cin >> option; switch(option) { case 1: system("cls"); c.AddCards(); break; case 2: system("cls"); cout << "Card ID:\t\t" << c.get_ID() << endl; cout << "\nCard Name:\t\t" << c.get_Name() << endl; cout << "\nMessage for the receiver:" << c.get_Message() << "\n\n"; break; case 3: int id; cout << "Enter Card ID:"; cin >> id; if(c.get_ID()!=id){ cout << "Card not found!\n"; system("pause"); exit(0); } else { cout << "\nDo you really wish to delete Card?"; cout << "\nCard ID:" << c.get_ID() <<"\tCard Name:" << c.get_Name(); cout << "\n\nPress 'y'or 'Y' to confrim:"; cin >> selection; } if (selection == 'y'||selection == 'Y') c.~Cards(); break; } cout << endl << endl; } } else cout << "\n\n\t\tIllegal selection! Please run the program again."; cout << endl << endl << "\t\t"; system("pause"); } /* ********************************************************************************** 2nd Part ********************************************************************************** // Declaration of template class template class User; template class Member; template class Admin; template class Cards; template class BirthCards; template class FriendshipCards; template class MarriageCards; template class BaaratCards; template class MehindiCards; template class WalimaCards; // Declaration of template data members and member fucntions template class Cards{ W id; W * name; public: Cards(W _id, W * _name); template void SetName(char *){ } ~Cards(); }; // Implementation of template constructor template Cards ::Cards(W _id, W * _name){ } // Implementation of template class destructor template Cards::~Cards(){} // Iheritance between MehindiCards and Cards template class MehindiCards: public Cards{ }; */