Create a `std::shared_ptr sp1` holding a value read from input. Print its reference count using `use_count()`. Then create a second `std::shared_ptr sp2 = sp1;` and print the `use_count()` of `sp2`.
A single integer.
Print 'Count1: [val]' then 'Count2: [val]'.
None
10
Count1: 1
Count2: 2
A shared pointer allows multiple pointers to own the same resource. It tracks how many pointers are looking at it, only deleting the memory when the count reaches 0.
#include <iostream>
#include <memory>
int main() {
int val;
if (std::cin >> val) {
// Implement shared_ptr logic and use_count check
}
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