I need help on how to store the item in a dynamically allocated object from standard input.
I am pretty lost because my professor from my last class never taught us this and this professor expects us to know this already.
GroceryItem.hpp
#include <iostream>
#include <string>
class GroceryItem
{
private:
std::string _upc;
std::string _brandName;
std::string _productName;
double _price;
public:
GroceryItem();
std::string upc();
void upc(std::string number);
std::string brandName();
void brandName(std::string name);
std::string productName();
void productName(std::string name);
double price();
void price(double amount);
};
GroceryItem.cpp
#include "GroceryItem.hpp"
#include <iostream>
#include <string>
GroceryItem::GroceryItem() :
_upc("NULL"), _brandName("NULL"), _productName("NULL"), _price(0.00)
{
}
std::string GroceryItem::upc()
{
return _upc;
}
void GroceryItem::upc(std::string number)
{
number = _upc;
}
std::string GroceryItem::brandName()
{
return _brandName;
}
void GroceryItem::brandName(std::string name)
{
name = _brandName;
}
std::string GroceryItem::productName()
{
return _productName;
}
void GroceryItem::productName(std::string name)
{
name = _productName;
}
double GroceryItem::price()
{
return _price;
}
void GroceryItem::price(double amount)
{
amount = _price;
}
I need to store this into a dynamic object then store the pointer to the object into a vector