'no suitable constructor exists to convert from "std::string () const" to "std::basic_string<char, std::char_traits<char>, std::allocator<char>>"
I'm trying to design a class "Book" which has members for a book's serial number, author, title, etc. I have put all these members in private and decided to make public functions to return these data values to the user without allowing any access to modifying these values. Code is given as follow:
#include "../../std_lib_facilities.h"
class Date
{
public:
//...
private:
int y, m, d;
};
class Book
{
public:
string ISBN() const { return ISBN; }
string title() const { return title; }
string author() const { return author; }
Date copyright_date() const { return copyright_date; }
bool availability() { return availability; }
void check_out();
private:
string ISBN;
string title;
string author;
Date copyright_date;
bool availability;
};
I'm currently getting this error from this code,
E0415 no suitable constructor exists to convert from "std::string () const" to "std::basic_string<char, std::char_traits, std::allocator>"
Please ignore the header file as it has no part in this problem. It's a custom header which allows access to multiple standard library functions and user-defined functions at once.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
