Create a `Distance` class with an integer `meters`. Overload the `float()` typecast operator to return the distance in kilometers (`meters / 1000.0f`). Read an integer, instantiate the object, explicitly cast it to float, and print the resulting float.
A single integer.
Print the distance in kilometers.
None
1500
1.5
Type conversion overloading `operator float()` allows custom objects to seamlessly cast themselves to basic primitive types.
#include <iostream>
class Distance {
public:
int meters;
Distance(int m) : meters(m) {}
// Write your type conversion overload here
};
int main() {
// Read input, instantiate, cast to float, and print
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