Skip to content

Instantly share code, notes, and snippets.

@jeanmikaell
Created May 23, 2013 15:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeanmikaell/5636990 to your computer and use it in GitHub Desktop.
Save jeanmikaell/5636990 to your computer and use it in GitHub Desktop.
// ******************************************
// 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;
}
// ******************************************
// 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();
}
#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