VUsolutions Transferred to AchiKhasi.com

From December 2011, this blog www.VUsolutions.blogspot.com is transferred to http://achikhasi.com/vu/ . So, you may visit http://achikhasi.com/vu/ for latest study related help.

Back to home VUsolutions

VUsolutions Fans Club [join us for MORE solutions]

VUsolutions on Facebook

CS304 Assignment No. 4 solution

Friday, July 01, 2011 Posted In Edit This
#include<iostream.h>
#include<conio.h>
class House;
class Room
{
       public:Room() {
                      };
                     static void createRoom_v(Room*(&room), House*hse,
                      char*name)
                  {
                                 room=new Room(hse, name);
                }
                        Room(House*hse, char*myName)
                        {
                         cout<<"\nPakistaniCitizens";
                          myHse_p=hse;
                          if(NULL!=myHse_p)
                                     {
                      name_p= new char(sizeof(strlen(myName)));
                                     name_p = myName;
                                     }
                           else
                                     {
                                     cout<<"\nPlease enter the age of the citizen";
                           }                                
                                     };
                                       ~Room()
                                       {
                                                cout<<"\nPakistaniCitizens";
                               myHse_p=NULL;
                             delete (name_p);
                                       };
                                void disp()
                                       {
                                 cout<<name_p;
                                       cout<<"\n";
                                       }
                                        static void initList_v(Room*(& roomsList_p)[3])
                                        {
                                                roomsList_p[3]=new Room[3];
                                        }
                                         private:House*myHse_p;
                                         char*name_p;
                                         };
                                         class House{ public:House(char *myName)
                                         {
                                         cout<<"\n PakistaniCitizens \n";
                                                name_p = new char(sizeof(strlen(myName)));;
                                                name_p = myName;
                                                Room::initList_v(roomsList_p);
                                                Room*myRoom;
                                                Room::createRoom_v(myRoom, this, "name");
                                                roomsList_p[0] = myRoom;
                                                Room::createRoom_v(myRoom, this, "age");
                                                roomsList_p[1] = myRoom;
                                                Room::createRoom_v(myRoom, this, "CNIC No");
                                                roomsList_p[2] = myRoom;
                                                }
                                                ~House()
                                                {
                                                         cout<<"PakistaniCitizens\n";
                                                    unsigned int i;
                                                         cout<<"Eligible for vote cast...\n";
                                                         for(i=0; i<3; ++i)
                                                     {
                                                         if(roomsList_p[i] != NULL)
                                                         { delete (roomsList_p[i]);
                                                    } }                                                  
                                                            delete [] roomsList_p;
                                                      delete (name_p);
                                                     } void disp()
                                                    { cout<<"\n\nPakistaniCitizens :"<<name_p;
                                                            if(roomsList_p != NULL) { unsigned int i;
                                                            cout<<"\n\nVotersList...\n";
                                         for(i=0; i<3; ++i) { if(NULL != roomsList_p[i])
                                             {
                                                 roomsList_p[i]->disp();
                                                  }
                                                    }
                                                       cout<<"\n\n";
                                                              }
                                                              }
                   private:
                        char*name_p;
                        Room*roomsList_p[3];
                        };
                        int main()
                        { cout<<"\nExample of Composition Relationship\n";
                        cout<<"-----------------------------------------\n\n";
                        House hse("data members"
                        );
                        cout<<"\n\nPakistaniCitizens...\n";
                        hse.disp();
                        cout<<"Age is less than 18...\n";
                        return(0);
                        }

Back to home VUsolutions

Shaadi.com: Just create ur account & find ur partner or EARN money, its reall & EASY

VUsolutions Followers (Join NOW and Get Extra Benefits)

Install LATEST toolbar having lot of features - GET solutions on Desktop

toolbar powered by Conduit
Caliplus 300x250 NoFlam VitoLiv 468x60 GlucoLo