Write a C++ program implementing a factory method returning `std::unique_ptr` to instantiate graphic shapes dynamically.
A choice character ('C' for Circle, 'R' for Rectangle).Print shape name created by factory.
Choice is C or R
C
Created Circle
Factory functions combined with smart pointers enforce safe object creation and ownership transfer.
#include <iostream>
#include <memory>
class Shape {
public:
virtual void draw() = 0;
virtual ~Shape() {}
};
class Circle : public Shape {
public:
void draw() override { std::cout << "Created Circlen"; }
};
class Rectangle : public Shape {
public:
void draw() override { std::cout << "Created Rectanglen"; }
};
std::unique_ptr<Shape> createShape(char type) {
// Implement factory function logic here
}
int main() {
char type;
if (std::cin >> type) {
auto shape = createShape(type);
shape->draw();
}
return 0;
}Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used