mercredi 25 novembre 2020

Compilation error “room.cpp:37:14: error: ‘Room’ has not been declared”

I am trying to compile this cpp file, yet it prints out following error message.

room.cpp:21:1: error: ‘Room’ does not name a type Room::Room()

I have applied solutions that are already provided online. Could you please guide me what to do?? It may be the order of "include library"?

enter image description here

#include <stdio.h> 
#include <stdlib.h>                                                                                                                        
#include <string.h>
#include <unistd.h>
#include <pthread.h>
#include <cstdint>
#include <iostream>
#include <list>
#include <algorithm>
#include "server.cpp"
#include "client.cpp"
#include "room.h"
#include "errorHandler.cpp"

// TODO: if errorHandler contains some libraries, does that inherit to the current cpp file as well?
// TODO: Make sure that the constructor works
// If Room is created without RoomNo, create Lounge

class Room(){

public: 
    Room(); 
    Room(int RoomNo);
    
    enter(Client client);

private:
    int RoomNo;
    Client client;
}


Room::Room()
{
    Lounge* lounge;
}

// If Room is created with RoomNo, create ChatRoom with RoomNo
Room::Room(int RoomNo);
{
    ChatRoom* chatRoom(RoomNo);
}

virtual void Room::enter(Client client)
{
    bool foundClient = (std::find(client_list.begin(), client_list.end(), client) != client_list.end());
    if (foundClient) {
        std::set_unexpected(errorHandler::room_unexp);
        try {
            errorHandler::room_bad_exception();
        } catch(const std::bad_exception& e) {
            std::cerr << "Caught " << e.what() << "\n";
        }

    } else {
        client_list.push_back(client);
        enterExitMessage(client, true);
    }
};

I want to know how to fix the error I mentioned above!

Aucun commentaire:

Enregistrer un commentaire