void RB_number()
{

	int roomnumber;
	string category;
	string type;
	string status;
	float rate;
	int roomid;


//Try,catch and throw  statement for exception handling to catch errors that are inputed from the user
		try
		{
			
			cout<<"\n\n\t\t\tEnter the Room ID you wish to view:";
			cin>>roomid;

			if(roomid < 0)
				throw "Error";
		}

		catch(string)
		{
			cout << "\n\n\t\t\tYou have entered and incorrect option.";
			cout << "\n\n\t\t\tPlease try again.";
			cout << "\n\n\t\t\tPress any key to continue:";
			getch();
			system("cls");
			RB_number();
			break;
		}
		

		
		//opens a file stream for the room text for reading
		fstream file;
		file.open( "room.txt", ios::in);

		//File erroe checking
		if ( !file )
			 {
				cerr << "\n\n\t\t\tFile could not be opened" << endl;
				cout << "\n\n\t\t\tPress any key to continue:";
				getch();
				system("cls");
				RB_number();
			 } 
		

		room * data;

		//Read the contents of the file and outputs it to screen
		while(file >> roomnumber >> category >> type >> status >> rate )
		{	
			//Dynamic binding of a instance of a class
			data = new room;

			//Pointer from a n instance of a class to a mutator
			data->createroom(roomnumber,category,type,status,rate);
			
			if(roomid==data->getroomnumber())
			{
				data->display();
				break;
			}
			else
			{
				cout<<"\n\n\t\t\tThe Room does not exist or Incorrect Room ID entered";
				break;
			}
		}

		//Closes the file stream
		file.close();

		cout<<"\n\n";
		//Call to destructor to destroy object
		data->~room();


		cout<<"\n";
		cout << "\n\t\t\tPress any key to continue:";getch();
}

The compiler is ignoring the if statement and I can't find why

Which if statement? If you could make the smallest compilable example that demonstrates the problem and tell is exactly what is happening and what you would expect to happen, that would be very helpful.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.