Created
May 23, 2013 15:37
-
-
Save jeanmikaell/5636990 to your computer and use it in GitHub Desktop.
This file contains 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
// ****************************************** | |
// Description: Application entry point. | |
// ****************************************** | |
#include <iostream> | |
#include <string> | |
#include "Sales_item.hpp" | |
int main() | |
{ | |
std::string bookName; | |
std::cin >> bookName; //requires the user to type a string on the command prompt | |
Sales_item book(bookName); //construct the object | |
std::cout << book.GetName() << std::endl; // retrieve & print the item name on the command prompt | |
return 0; | |
} |
This file contains 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
// ****************************************** | |
// Description: Sales_item class definition | |
// ****************************************** | |
#include "Sales_item.hpp" | |
Sales_item::Sales_item(std::string itemName) //constructor | |
{ | |
m_Name = itemName; | |
}; | |
const char * Sales_item::GetName() | |
{ | |
return m_Name.c_str(); | |
} |
This file contains 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 _SALES_ITEM_HEADER_GUARD_ //prevent the header from being included twice in the same .cpp file | |
#define _SALES_ITEM_HEADER_GUARD_ | |
// ****************************************** | |
// Description: Sales_item class declaration | |
// ****************************************** | |
#include <string> | |
class Sales_item | |
{ | |
public: | |
Sales_item(std::string itemName); //constructor | |
const char * GetName(); // Name accessor | |
private: //member variables | |
std::string m_Name; | |
}; | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment