Overloaded + constructor

I am having an issue getting my overloaded + constructor to work. Here is the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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!
Well, I can only see two constructors:
Book (); // takes no arguments

Book (string author, string booktitle, int datePublished); // takes, string,string,int arguments


So how does a constructor with a single int argument work?
1
2
Book bk1 (1991);
Book bk2 (1954);

You don't appear to have defined one.
Last edited on
Yeah, just a few minutes after I posted, I aksed a friend of mine and he helped me with it. But thanks anyway!
Topic archived. No new replies allowed.