You are developing a firmware-style C++ class that stores sensor readings inside a dynamically allocated byte buffer.
Each buffer instance must own its memory exclusively and follow correct ownership and lifetime rules.
Your task is to implement the copy assignment operator so that assigning one object to another using:
A = B; performs a deep copy.
A deep copy means:
If implemented incorrectly, the program may suffer from:
What the class must support
The SensorBuffer class must implement:
The class also provides helper functions to:
Program Flow
N1 followed by N1 byte values → initialize object AN2 followed by N2 byte values → initialize object BA = BAfter the assignment:
Example Input
5
1 2 3 4 5
5
9 9 9 9 9Example Output
9 9 9 9 9
Constraints
new[]delete[]
Input
4 10 20 30 40 4 1 1 1 1
Expected Output
1 1 1 1