I want from user a page number and and a book name, then display it by using classes and set() get() functions.However,I couldn't understand why my function sending just the integer value to the function in class and not taking the info in string.
enter code here
#include<string>
#include<iostream>
using namespace std;
class Book
{
private:
int Page;
string Name;
public:
Book(int page,string name)
{
setPage(page);
setName(name);
}
void setPage(int page)
{
Page=page;
}
int getPage()
{
return Page;
}
void setName(string name)
{
Name=name;
}
string getName()
{
return Name;
}
};
int main()
{
int pages;
string nameofbook;
cout<<"Please enter the page of the book: ";
cin>>pages;
cout<<"Please enter name of the book: ";
getline(cin,nameofbook);
Book mybook(pages,nameofbook);
cout<<mybook.getName()<<"has"<<" "<<mybook.getPage()<<"pages"<<endl;
return 0;
}