Created
          July 12, 2015 13:37 
        
      - 
      
- 
        Save krysseltillada/52addae29cf5bc522fb0 to your computer and use it in GitHub Desktop. 
    class exercise
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #include <iostream> | |
| #include "exercise.h" | |
| int main() | |
| { | |
| Book b1("lippman", "c++primer", "blahblah", "2211"); | |
| display(b1); | |
| b1.modify_author("kryssel").modify_title("blah blah").modify_date("nov 28 1998").modify_isbn("2220-222"); | |
| display(b1); | |
| return 0; | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #ifndef EXERCISE_H | |
| #define EXERCISE_H | |
| class Book | |
| { | |
| public: | |
| friend void display (Book &); | |
| Book (std::string a,std::string i,std::string d, std::string t) : | |
| author (a), isbn (i) , date (d), title (t) { } | |
| Book &modify_author (const std::string &); | |
| Book &modify_isbn (const std::string &); | |
| Book &modify_date (const std::string &); | |
| Book &modify_title (const std::string &); | |
| private: | |
| std::string author, isbn, date, title; | |
| }; | |
| void display (Book &o) | |
| { | |
| std::cout << o.author << std::endl | |
| << o.isbn << std::endl | |
| << o.date << std::endl | |
| << o.title << std::endl; | |
| } | |
| Book &Book::modify_author (const std::string &p) | |
| { | |
| this->author = p; | |
| return *this; | |
| } | |
| Book &Book::modify_isbn (const std::string &p) | |
| { | |
| this->isbn = p; | |
| return *this; | |
| } | |
| Book &Book::modify_date (const std::string &p) | |
| { | |
| this->date = p; | |
| return *this; | |
| } | |
| Book &Book::modify_title (const std::string &p) | |
| { | |
| this->title = p; | |
| return *this; | |
| } | |
| #endif // EXERCISE_H | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment