What does your book class have to do with employee salaries?
PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.
#include <iostream>
#include <string>
usingnamespace std;
class book{
private:
int id;
string name;
int pages; // changed n to pages to make it easier to understand
public:
void add(){
cout << "Enter book ID number" << endl;
cin >> id;
cout << "Enter book name" << endl;
cin >> name;
cout << "Enter number of pages" << endl; // changed to make it easier to understand
cin >> pages;
cout << endl;
}
int getPages(){ return pages; } // changed the name of this function to make it easier to understand
string getName(){ return name; } // added this function to get the name
};
int main(){
book ad, c; // you have to create books here in order to use them
// run these 2 functions to enter information about the books
ad.add();
c.add();
// Now that the books have been created, you can compare instances of both
if(ad.getPages() > c.getPages()){
cout << ad.getName() << " has " << ad.getPages() - c.getPages() << " more pages." << endl;
}
elseif(ad.getPages() < c.getPages()){
cout << c.getName() << " has " << c.getPages() - ad.getPages() << " more pages." << endl;
}
else{
cout << ad.getName() << " and " << c.getName() << " have the same number of pages." << endl;
}
return 0;
}