Reputation:
need your help.
Lets say that I have 2 classes: class Category
and class Product
.
Here its implementation
class Category
{
private:
string _category Name;
vector<string> _categoryVector;
public:
void Add()
{
cout << "\n=== ADD <CATEGORY> ===" << endl;
cout << "\nEnter <Category> Name: ";
cin >> _categoryName;
_categoryVector.push_back(_categoryName);
};
}
class Product
{
private:
string _productName;
double _productPrice;
map<string, double> _productMap;
public:
void Add()
{
cout << "\n=== ADD <PRODUCT> ===" << endl;
cout <<"\nEnter <Product> Name: ";
cin >> _productName;
cout << "\nEnter <Product> Price: ";
cin >> _productPrice;
_productMap.insert(pair<string, double>(_productName, _productPrice));
};
}
void main()
{
Category c;
c.Add();
c.Add();
Product p;
p.Add();
p.Add();
system("pause");
}
I want to store Product in Category. To make some logic in this program.
Is it possible to do this?
Thanks.
Upvotes: 0
Views: 991
Reputation: 598
I don't understand what you want in your program but
if you just want to store map
in vector
Use follow:
std::vector<std::map<std::string, double> >
Upvotes: 2