Ok this is a huge topic. But the main things you need to do is:
1) In your tool "save" any data you need to undo the thing you did
2) In your UndoFunc, add code that accesses this "saved" data and does whatever is needed to undo the thing you did. And save any additional data you might need to "redo" what you just "undid".
3) Similarly in your RedoFunc, add code that accesses this "saved" redo-data and does whatever is needed to redo the thing you original did.
It is that simple but the code is something each different tool has to figure out... what to save, how to "undo" what the tool did and how to "redo" what was originally done after the user undoes.
This is explained in very much detail in Volume 2 of the User Guide. There each part of the undo/redo work flow is described.
After making the plugin i found that undo and redo functions are not defined. I went through the sample undotest plugin sample but I am not able to figure out how it works, sorry to say but even after. I'll paste the code but can someone suggest where and how to add undo and redo.
This is the sample code for which i want to add Undo Redo function, By default Plugin Wizard added few lines for Undo Redo function but I am not that much expertise in it.