Create a class BufferTracker that simulates processing bytes in a communication buffer (UART, SPI, DMA, etc.).
Each time addByte() is called, an internal counter increases.
When the object is destroyed, the destructor must automatically print:
PROCESSED=<count>
This simulates firmware that logs how many bytes were processed during a communication transaction.
Class Requirements:
count, initialized to 0count = 0void addByte(int b) increases count by 1PROCESSED=<count>Program Behavior:
n — number of bytesBufferTracker object inside a scoped block { }n byte values (values are irrelevant)addByte()⚠️ Nothing should be printed inside the block — only the destructor prints output
Example 1
Input:
5
10 20 30 40 50
Output:
PROCESSED=5
Example 2
Input:
0
Output:
PROCESSED=0
Constraints:
addByte() calls
Input
5 1 2 3 4 5
Expected Output
PROCESSED=5