Please help me with this C project on class This is what I h
Please help me with this C++ project on class. This is what I have below and please edit and critique me as needed. I am just learning this stuff. Here is the original question: \"create a c++ class called Book that has member variables pages, position, author, publisher, year. Create member functions to change all of these and create a value pass and default constructor.\"
class Book
{
Public:
Book ();
Book (int pages, double position, std::string author, std::string publisher, int year);
private:
int num_of_pages;
int num_of_position;
string name_of_author;
string name_of_publisher;
int num_of_year;
};
Book :: Book ()
{
num_of_pages = 250;
num_of_position = 50;
name_of_author = Steven King;
name_of_publisher = Simon & Schuster;
num_of_year = 1982;
}
Book :: Book (int pages, int position, string author, string publisher, int year)
{
num_of_pages= pages;
num_of_position = position;
name_of_author = author;
name_of_publisher = publisher;
num_of_year = year;
}
Solution
class Book
{
Book ();
Book (int pages, double position, std::string author, std::string publisher, int year);
protected:
int pages;
int position;
string author;
string publisher;
int year;
public:
void setpages(int p) {
pages = p;
}
void setPosition(int pos) {
position = pos;
}
void setAuthor(int auth) {
author = auth;
}
void setpublisher(int pub) {
publisher = pub;
}
void setYear(int y) {
year = y;
}
}
Book :: Book (int p, int pos, string auth, string pub, int y)
{
pages= p;
position = pos;
author = auth;
publisher = pub;
year = y;
}

