Question: Follow the given pre/post conditions to implement. You may depend on almost all member functions in transaction_log, transaction, and long_decimal and assume they operate to
Follow the given pre/post conditions to implement.
You may depend on almost all member functions in transaction_log, transaction, and long_decimal and assume they operate to the specification.
You may NOT call transaction_log's append, insert, or reserve member functions.
Your job, IMPLEMENT the function below:
// Precondition: current is valid // Postcondition: The transactions from current to end of the log are REPLACED with the sum. // The capacity is reduced by the number of transactions removed - 1 (to give room for the sum). // For example, if the log was [12, -5, 4, 8] and current_index is 1 // The log will now be: // [12, 4] because -5+4+8 is 7 // Note: The example above is with integers, the actual transaction contains long_decimal // **This function may NOT depend on insert, append, or reserve.** void sum_and_collapse(); |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
