I know if i will not use the pointer base class function "virtual double grossPay" will be called for both base class object and derived class object and when i will use pointer with reference to the object because base class function is virtual it will look for same function in derived class and if available it will execute it.
I think my concept about pointers is not clear any help to understand this will be highly appreciated.
Sorry for my english but i think i explain my point.
Because that's the point of subclassing. :) The whole point is that the caller doesn't need to know whether it's an employee, a manager, or whatever. It doesn't care. It can take a pointer to either. When you call a virtual function on such a pointer, it'll use the appropriate virtual function - if it's pointer to an employee, it'll call employee::grossPay, while if it's a pointer to a manager, it'll call manager::grossPay. Any function that's not overridden will use the base class's version.
If you needed to know whether you were dealing with a pointer to a manager or a regular employee, that'd kind of defeat the point, now wouldn't it? :)
Thanks ne555 and Nafnlaus, for both of you for replying to this question and now i am totally understand that what was happening and why i need pointer when dealing with virtual functions.
Object Slicing was confusing me so much but i am happy that i understand what was happening.