So I have a struct called CompanyInfo.
1 2 3 4 5 6 7
|
struct companyInfo{
string companyName; // Name of the Company
products; // Company's products
vector<string> VecProducts;// number of products in unknown, so putting them in a vector
};
companyInfo myNewComp;
vector<companyInfo>myVec; // All the information goes here
|
Then When user calls the Add function, I ask for Name of company and ask for its products. And store everything in a vector
1 2 3 4 5 6 7 8 9 10 11
|
void Add(){
cout << " Company Name: ";
cin >> myNewComp.companyName; // User can enter "samsung, apple, sony etc."
do{
cout << " Product: "
cin >> myNewComp.products; // User can enter "cellphones, tvs, camera etc."
myNewComp.VecProducts.push_back(myNewComp.products);
myVec.push_back(myNewComp);
} while(products != "zzz") // stop loop after user hits "zzz"
}
|
So everything is fine until this point. Now lets says that the user enter adds 3 companies and its products.
Samsung (products: TVs, camera, smartphones)
Apple (products: smartphones, tablets, laptops)
Sony (products: camera, TVs, headphones)
Now in the Search() function, I ask the user to enter a product he is looking for, and in the vector, I keep only those companies that sell this product. So if user is looking for camera, I delete Apple and its products and keep only Samsung and Sony.
HOW DO I THEN DO THAT? I DON'T KNOW HOW TO DELETE 'APPLE AND ITS PRODUCTS'