そのため、病室をシミュレートするクラスルームを作成しようとしていますが、コンストラクターでエラーが発生し続けます。問題がない場合もありますが、戻ってくることがあります....ここにある他のユーザー定義オブジェクトには、問題のない患者クラスと問題のない LinkedList テンプレート クラスが含まれます。
ヘッダーはこちら
class Room
{
public:
Room();
Room(int);
static LinkedList<Room> createRooms();
Patient patient;
int roomNumber;
bool operator==(const Room &other) const; //overload ==
bool operator!=(const Room &other) const; //overload !=
void operator=(const Room &other) const; //overload =
};
そしてcpp
#include "Room.h"
Room::Room();
Room::Room(int n)
{
roomNumber= n;
patient= Patient();
}
LinkedList<Room> Room::createRooms() {
//create rooms up until ROOMS is reached
LinkedList<Room> roomList;
for(int i= 1; i < 11; i++){
Room room= Room(100+i);
roomList.push(room);
}
return roomList;
}
//Overload ==
bool Room::operator==(const Room &other)const{
//compare each room's room number field
return (this->roomNumber == other.roomNumber && this->patient == other.patient);
}
//Overload !=
bool Room::operator!=(const Room &other)const{
return !(this == &other);
}
void Room::operator=(const Room &other)const{
this->patient= other.patient;
this->roomNumber= other.roomNumber;
}
問題は Room(int) コンストラクタにあります。Xcode は、関数スタイルのキャストまたは型の構築に '(' が必要であるというメッセージを表示し続けます
何が起こっているのかわかりません