Class function example from C++ book by D.S. Malik for practice