The code below for 15 puzzle, my task is to present it as the following syntax, but I am confused that is it possible to represent the code in this way below :
once p15 is presented as an abstract class code such as above would no longer be possible as you can't create instances of an abstract class. The way around that would then be inheritance and pointers:
The abstract base class p15 could be a framework for solving a number puzzle. The logic for solving the puzzle could be built into the base class, and the data representation and display are up to the developers of the derived class.
In other words, the algorithm to solve the puzzle is either encapsulated in the base class or resides outside of the class completely. All the algorithm knows about the inner workings of the puzzle class is that it can call GetBlock, MoveBlock and show.
Maybe I want to store the data for the puzzle in an array of uchars where each nibble represents one of the blocks, and display information to the console. Maybe my friend want to store the puzzle in a 2-dimensional array of shorts and display on a GUI window. The algorithm to solve the problem does not care as long as GetBlock, MoveBlock and show do what is is expected.