Create a vector in the main program that will store the dynamic objects of the Clothing class and create the function getClothesTotal (vector <Clothes *> shopping), which calculates the value of the entire purchase.
I have this code in main, and i tried to create function getClothesTotal, but it doesn't works. If someone knows how to solve this please help :D
1 2 3 4 5 6 7 8 9 10
vector<Clothes> MyClothes;
Clothes* a = new Clothes("man ", "coat",42,150);
Clothes* b = new Clothes("woman", "coat",38,160);
Clothes* c = new Clothes("woman","dress",36,80);
a->print();
b->print();
c->print();
delete a;
delete b;
delete c;
I have this function in my class:
double getClothingTotal(std::vector <Clothing *> shopping) {
double total = 0.0;
std::vector<Clothing*>::iterator VectorPointer;
for (VectorPointer = shopping.begin(); VectorPointer != shopping.end(); ++VectorPointer) {
total += VectorPointer->getPrice();
}
return total;
but there are so many errors. First i need to store dynamic objects in vector, and then to create this function, but it doesn't works.. I don't even know where to start
double Clothing::getClothingTotal(const vector<Clothing*> &shopping) {
return 0;
}
I create function and now i have to use getPrice() inside this function to calculate all the prices