Monday, May 24, 2010

Correct my c ++ programe?

//sheet#2, Ex#2





#include%26lt;iostream%26gt;


using namespace std;





class HotelRoom // hotel room class definition


{





private:





int room_number ; //room number enter by user


int floor_number; //floor number enter by user


int type; //type of room enter by user


int booking; //booking enter by user





public:





SetRoomInfo(Ri); //


SetfloorInfo(Fi);


settypeoInfo(Ti);


setbookedInfo(Bi);








void ShowRoomInfo(){ // display show room info


cout%26lt;%26lt;"Number Of room is : "%26lt;%26lt; Ri;


cout%26lt;%26lt;"Number Of floor is : "%26lt;%26lt; Fi;


cout%26lt;%26lt;"type:" %26lt;%26lt;Ti;


cout%26lt;%26lt;booked:" %26lt;%26lt;Bi;





}





void CheckRoomStatus(){


If ( booking ==0 ) //if booking is equal to eual 0


booking free;





If ( booking ==1 ) //if booking us equal to equal 1


booking booked;





} // end if





void Booking(){


cout%26lt;%26lt;"what is advance of room";


cin%26gt;%26gt;the room number is 100,located in the second floor,it is a dubble room and available for booking





} // end function void chec room














}; // end class hotel room





//-----------------





int main() // function main begen brogram execution


{


hotel rom call;


call.setroom_number;


call.setfloor_nimber;


call.settype;


call.setbooking;





return 0;


}


//------------------- The End ----------------------

Correct my c ++ programe?
There's, like, a lot wrong with that. Recommend you get some serious, in-person help with your program.
Reply:I won't correct all of it, but I will put you more on track than you are now.





First, any class will have to have a constructor and a destructor even if they are only default versions.





Example:





class My_Class{


private:


int My_Num;


public:


void Set_My_Num();


void Show_My_Num();


My_Class(){} //Constructor


~My_Class(){} //Destructor


}; //Note the semi-colon, needed for class // definition.





Now, secondly, somewhere before you use the program, you need to define the functions for the class interface.


Examples:





void My_Class::Set_My_Num(){


int num;


cout %26lt;%26lt; "Enter an Integer: ";


cin %26gt;%26gt; num;


My_Num = num;


}





void My_Class::Show_My_Num(){


cout %26lt;%26lt; My_Num %26lt;%26lt; endl;


}





void main(){





My_Class object;


object.Set_My_Num();


object.Show_My_Num();


}





While the examples don't directly address the application you're writing, it should point out some omissions that are serious in your code.


I hope I've helped you out a bit. Pivy


No comments:

Post a Comment