Polymorphism in C++
Polymorphism in C++
• 1. Create a base class `Product` with common attributes (`name`, `price`) and a virtual method
`getDescription()`.
• 2. Derive two subclasses:
• - Book: Add an `author` attribute and override `getDescription()` to include book details.
• - Electronics: Add a `brand` attribute and override `getDescription()` to include electronics details.
• 3. Use a static array of `Product` pointers to store objects of `Book`, `Electronics`, and `Product`.
• 4. Write a function to iterate through the array and display the details of each product using
polymorphism.
• 5. Ensure proper memory management by deleting dynamically allocated objects.