class Book
{
private:
BookAuthor author1;
string authorName;
string title;
int date;
public:
Book ()
{
authorName = author1.getAuthorName ();
title = author1.getBook ();
date = 1985;
}
Book (string author, string booktitle, int datePublished)
{
BookAuthor author2 (author, title);
authorName = author2.getAuthorName ();
title = booktitle;
date = datePublished;
}
void Display ()
{
cout << "Book information: \n"
<< "Author: " << authorName << endl
<< "Title: " << title << endl
<< "Publishing date: " << date << endl;
}
friend Book operator+ (Book dateInitial, Book dateMore);
};
// Overloaded constructor
Book operator+ (Book dateInitial, Book dateMore)
{
return Book (dateInitial.date + dateMore.date);
}
Here's the call to the overloaded constructor in main:
1 2 3 4 5
Book bk1 (1991);
Book bk2 (1954);
Book bk3;
bk3 = bk1 + bk2;
All I am getting when I try to compile it is an error that says
error: no matching conversion for functional-style cast from 'int' to 'Book'
return Book (dateInitial.date + dateMore.date);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I don't know what I did wrong but I can't seem to figure it out. Its not the return type because that's Book too, but I don't see what else it could be. Thanks!