Create a class Filter3 that represents a simple 3-coefficient digital filter used in embedded signal processing.
This problem focuses on correct use of constructor initialization lists in Embedded C++, which are mandatory when initializing const members and fixed-size arrays.
All internal members must be initialized using a constructor initialization list, not by assignment inside the constructor body.
Class Requirements
const int idint coeff[3]int lastOutputFilter3(int filterId, int c0, int c1, int c2)id initialized with filterIdcoeff initialized as {c0, c1, c2}lastOutput initialized to 0void apply(int x)lastOutput = x * coeff[0] + coeff[1] + coeff[2]; int read()lastOutputIn main()
id, c0, c1, c2Filter3 objects1 and s2apply(s1) and then apply(s2)read()
Example Input
7 2 3 1
10 4
Example Output
12
Explanation
{2, 3, 1}apply(10) → 10 * 2 + 3 + 1 = 24apply(4) → 4 * 2 + 3 + 1 = 1212
Constraints
Input
7 2 3 1 10 4
Expected Output
12