|
The reason for the error is that the argument to both functions is a const pointer, but you're attempting to copy it to a non-const pointer. Doing such a thing would provide a direct means of modifying a const object, and the compiler refuses.
The solution is to use a technique that does not (implicitly or explicitly) to remove the const'ness of the pointer. A poor solution (which, if the person marking your exercise is awake, would result in lower marks) would be to bludgeon the compiler into submission by using a typecast.
Is getNext() a const method of IntNode? If it is, you will not need to use a typecast. If it isn't, then whoever gave you the assignment should be shot as the only solution would be to use a typecast.
Are you allowed to use recursion?
|