I'm new to programming and learning classes. I have a class Product and am trying to create an array of products, however my destructor is called three times for two objects and it triggers a breakpoint. Here is some of the code:
`
class Product {
private:
char* name;
int price;
public:
Product();
Product(const char*, int);
~Product();
};
`
Product::Product(const char* name, int price) {
this->name = new char[strlen(name) + 1];
strcpy(this->name, name);
this->price = price;
}
Product::~Product() {
delete[] this->name;
}
int main() {
Product redPaint("Red Paint", 25);
Product bluePaint("Blue Paint", 26);
Product paint[2] = { redPaint, bluePaint};
}