Why it gave me this error "[Error] invalid conversion from 'int' to 'const char*' [-fpermissive] Can someone help include #include using namespace std; class Book { private: public: string author; string title; int year; Book(string author, string title, int year) { this->author = author; this->title = title; this->year = year; } string getAuthor() { return author; } void setAuthor(string author) { this-> author = author; } bool publishedBefore(int y) { if(yearattendanceYear = attendanceYear; this->awardName = awardName; } string getAwardName() { return awardName; } int getAttendanceYear() { return attendanceYear; } void setAwardName(string awardName) { this->awardName = awardName; } void setAttendanceYear(int attendanceYear) { this->attendanceYear = attendanceYear; } string toString() { return "Given Award" + awardName + "\n" + "Written in year" + to_string(year); } }; int main () { // book1 1 Book book ("J.K.Rowing", "Fantastic Beats and where to find them- the Crimes of Grindelwald ", 2018); cout<
Why it gave me this error "[Error] invalid conversion from 'int' to 'const char*' [-fpermissive]
Can someone help
include <iostream>
#include <string>
using namespace std;
class Book {
private:
public:
string author;
string title;
int year;
Book(string author, string title, int year) {
this->author = author;
this->title = title;
this->year = year;
}
string getAuthor() {
return author;
}
void setAuthor(string author) {
this-> author = author;
}
bool publishedBefore(int y) {
if(year<y){
return true;
}
else {
return false;
}
}
string toString() {
cout<<endl;
return "Author: " + author + "\n" + "Book name: " + title + "\n" + "Written in year: " + to_string(year);
}
};
class AwardedBook : Book {
private:
int attendanceYear;
string awardName;
public:
AwardedBook(string author, string title, int year, int attendanceYear, string awardName) : Book(author, title, year) {
this->attendanceYear = attendanceYear;
this->awardName = awardName;
}
string getAwardName() {
return awardName;
}
int getAttendanceYear() {
return attendanceYear;
}
void setAwardName(string awardName) {
this->awardName = awardName;
}
void setAttendanceYear(int attendanceYear) {
this->attendanceYear = attendanceYear;
}
string toString() {
return "Given Award" + awardName + "\n" + "Written in year" + to_string(year);
}
};
int main () {
// book1 1
Book book ("J.K.Rowing", "Fantastic Beats and where to find them- the Crimes of Grindelwald ", 2018);
cout<<book.getAuthor()<<endl;
book.setAuthor("Robert Galbraith");
cout << book.getAuthor() << endl;
// book 2
Book book1 ("J.K. Rowing", "Harry Potter and The Chamber of seacret", 1998);
cout<<book1.getAuthor()<<endl;
book1.setAuthor("B.Rusev");
cout<<book1.getAuthor()<<endl;
// book 3
Book book2 ("George R. R. Martin","Games of thrones", 1996);
cout<<book2.getAuthor()<<endl;
book2.setAuthor("M.G.K");
cout<<book2.getAuthor()<<endl;
cout << book.toString() << endl;
int year = 2015;
cout<<endl;
// za book
if(book.publishedBefore(year) == true )
{
cout << "Knigata e pyblikyvana predi" <<" "<<year << endl;
}else
{
cout << "Knigata ne e pyblikyvana predi "<<" "<<year << endl;
}
// za book 1
if(book1.publishedBefore(year) == true )
{
cout << "Knigata e pyblikyvana predi" <<" "<< year << endl;
}
else{
cout << "Knigata ne e pyblikyvana predi"<< " "<< year << endl;
}
//za book 2
if(book2.publishedBefore(year) == true )
{
cout << "Knigata e pyblikyvana predi" <<" "<< year << endl;
}
else{
cout <<"Knigata ne e pyblikyvana predi"<<" "<< year << endl;
}
// Award for book
AwardedBook awb (2019,"Galaxy British Book Awards","J.K.Rowling", "The Crimes of Grindelwald",2018);
cout <<awb.getAwardName() << " " << awb.getAttendanceYear() << endl;
// Award for book 2
AwardedBook awb1(2001,"Whitaker’s Platinum Book Award", "J.K.Rowling","Harry Potter and the Chamber of Seacrets", 2002);
cout << awb1.getAwardName() << " " << awb1.getAttendanceYear() << endl;
// Award for book 3
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images