Book.h:
#ifndef BOOK_H
#define BOOK_H
#include <string>
class Author;
class Book {
public:
Book(const std::string title, const std::string publisher, const Author& author, int isbn, double price);
std::string getTitle() const;
Author getAuthor() const;
Book& setAuthor(const Author& author);
private:
std::string b_title;
std::string b_publisher;
Author b_author;
int b_isbn;
double b_price;
};
Author.h:
#include <string>
#ifndef AUTHOR_H
#define AUTHOR_H
class Book;
class Author {
friend Book::getAuthor() const;
friend Book::setAuthor(const Author& author);
public:
Author(const std::string& name, const std::string& email, Gender gender);
Author& setName(const std::string& name);
private:
std::string a_name;
std::string a_email;
int a_gender;
};
#endif
the error in author.h, on the friend function:
friend Author Book::getAuthor() const;
the error is:
error: invalid use of incomplete type 'class Book'
error: forward declaration of 'class Book'
previusly, you said it is a duplicate questions. I saw what you've written befor about that, but i'm afraid it didn't cover the error.