#include <iostream>
using namespace std;
class BufferTracker {
private:
int count;
public:
BufferTracker() : count(0) {}
void addByte(int b) {
count++; // Count processed bytes
}
~BufferTracker() {
cout << "PROCESSED=" << count;
}
};
int main() {
int n;
cin >> n;
{
BufferTracker tracker;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
tracker.addByte(x);
}
} // Destructor prints output
return 0;
}
Explanation & Logic Summary:
addByte() increments the count for each processed byteFirmware Relevance & Real-World Context:
Input
5 1 2 3 4 5
Expected Output
PROCESSED=5