Я продолжаю получать различные ошибки в своем коде, может ли кто-нибудь запустить его через свой компилятор и помочь мне решить их? Я установил несколько и один я получаю в настоящее время не существует функция согласования для вызова «аудитории :: аудиторий (станд :: строковых &, внутр &, .....C++ Ошибки с кодами классов
//classRoom.h
#ifndef CLASSROOMS_H
#define CLASSROOMS_H
#include <iostream>
#include <string>
#include "ClassRooms.h"
using namespace std;
class ClassRooms
{
public:
ClassRooms(int nRooms=100)
: numRooms(0), rooms(new ClassRooms[nRooms]) { }
~ClassRooms()
{
delete [] rooms;
}
void addRoom(const ClassRooms& cr)
{
rooms[numRooms++] = cr;
}
string findRoom(int seats)const;
int getSeats();
double getAreaPerSeat();
string getRoomNumber();
private:
int numRooms;
ClassRooms *rooms;
int numSeats;
double length, width;
};
#endif //CLASSROOMS_H
//ClassRooms.h
#ifndef CLASSROOMS_H
#define CLASSROOMS_H
#include <iostream>
#include <string>
#include "classRoom.h"
using namespace std;
class ClassRooms
{
public:
ClassRooms(int nRooms=100)
: numRooms(0), rooms(new ClassRooms[nRooms]) { }
~ClassRooms()
{
delete [] rooms;
}
void addRoom(const ClassRooms& cr)
{
rooms[numRooms++] = cr;
}
string findRoom(int seats)const;
private:
int numRooms;
ClassRooms *rooms;
};
#endif //CLASSROOMS_H
//main.cpp
#include <iostream>
#include <fstream>
#include "ClassRooms.h"
using namespace std;
int main()
{
ifstream fin("rooms.txt");
if (!fin)
{
cout << "Cannot open file\n";
return 1;
}
string roomNum;
int seats;
double len, wid;
ClassRooms classRooms;
while (fin >> roomNum >> seats >> len >> wid)
classRooms.addRoom(ClassRooms(roomNum, seats, len, wid));
fin.close();
while (seats > 0)
{
cout << "Enter MAX capacity: ";
cin >> seats;
cout << "Your best room is " << classRooms.findRoom(seats) << endl;
}
}
//ClassRooms.cpp
#include "classRoom.h"
string ClassRooms::findRoom(int seats)const
{
int maxIndex = 0;
while (maxIndex < numRooms && rooms[maxIndex].getSeats() < seats)
++maxIndex;
if (maxIndex == numRooms) return "";
for (int i = 0; i < numRooms; ++i)
if (rooms[i].getSeats() >= seats
&& rooms[i].getAreaPerSeat() > rooms[maxIndex].getAreaPerSeat())
maxIndex = i;
return rooms[maxIndex].getRoomNumber();
}
'classRoom.h',' ClassRooms.h', 'class ClassRooms',' class ClassRooms'. Я смущен. – dyp
Оба классаRoom.h и classRooms.h определяют класс ClassRooms, вы должны начать там. – igleyy
Добро пожаловать в StackOverflow. В вашем вопросе непонятно, какие проблемы вы столкнулись - вы должны попытаться включить фактические ошибки компилятора, которые вы получаете. При поиске справки по такой проблеме вы должны попытаться показать, с какими ошибками вы сталкиваетесь, и попытаться продемонстрировать, какие действия вы предприняли для их решения самостоятельно. См. Раздел [Как задавать вопросы] (http://stackoverflow.com/questions/how-to-ask) Часто задаваемые вопросы о том, как задавать вопросы. Здесь люди отвечают на вопросы, чтобы попытаться помочь, а не выполнять вашу работу за вас. – kfsone