Hello guys, when I've tried to create a constructor for class SmoothyCuFrica I receive this error "no default constructor exist for class DecoratorSmooty". Here is a diagram for easy understanding of my project https://gyazo.com/5ad2a44106d4969f5a7cf7e978291721.
you said that you construct a decorator_smoothy like this DecoratorSmoothy(const BasicSmoothy &s), so you need to provide a basic_smoothy to it.
like the line that you have commented out.
By the way
1 2 3
class DecoratorSmoothy :public Smoothy {
private:
BasicSmoothy s; //I don't see this in your diagram
I don't know why that doesn't appear in the diagram,i use visual studio 2015 diagram generator, BasicSmoothy it's s in the new diagram,i think the problem it's because BasicSmoothy have a constructor with an argument and after that DecoratorSmoothy have another one and i need to make a new constructor for SmoothyCuFrisca but doesn't work the same way as DecorathorSmoothy. Anyway my main function will look like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
int main() {
vector<Smoothy*> lista;
lista.push_back(new BasicSmoothy{ "kiwi" });
lista.push_back(new BasicSmoothy{ "capsuna" });
BasicSmoothy a{ "kiwi" };
DecoratorSmothy b{ "capsuna" };
lista.push_back(new DecoratorSmoothy{ a });
lista.push_back(new SmoothyCuFrisca { b }); // that doesn't work because i don't know how to make a constructor to work like that
for (auto smoothy : lista) {
cout << smoothy->descriere() << "\n";
cout << smoothy->getPret() << "\n";
}
return 0;
}