我正在为 MIT OCW 课程做一些事情,它要求编写一个“图书馆”课程。现在我有这个:
#include <iostream>
using namespace std;
class Book{
string title;
bool rented;
public:
Book(string bookTitle){
title = bookTitle;
}
void borrowed(){
rented = true;
}
void returned(){
rented = false;
}
bool isBorrowed(){
return rented;
}
string getTitle(){
return title;
}
};
class Library{
string Lname;
Book bookList[100000000];
int numOfBooks = 0;
public:
Library(string name){
Lname = name;
}
void addBook(string bookName){
bookList[numOfBooks] = Book(bookName);
numOfBooks += 1;
}
void returnInfo(){
cout << "Library hours:" << "\n" << "Libraries are open daily from 9am to 5pm." << "\n" << "Library addresses:" << "\n" << "10 Main St." << "\n" << "228 Liberty St.";
}
};
int main()
{
Library l = Library("Hi");
return 0;
}
当我编译它给我错误 no matching function for call to 'Book::Book()' for line 35。