The Computer Architecture course in the School of Electrical and Computer Engineering at National Technical University of Athens has an excercise where the student is asked to simulate a simple cache mechanism for a simple program.
This is a library that implements a "cached array", an array which holds some cache statistics. By performing only minimal changes to the given code ("[]" to "()" and probably changes to operations to satisfy order of operations) this library should help validate solutions to this excercise. (It will not solve the excercise, as it does not show any intermediate steps).
Compile any main* file you like with g++, run a.out, see the results :)