This is a part of code i read in a standard book..


int *ip;
ip=((int *)f);

my question is..f gives d address of function..then wat is d need to typecast..??/

7 Years
Discussion Span
Last Post by Narue

Not enough information, which is why you have been down-voted. There are a lot of "standard books" that I wouldn't use to wipe... you get my meaning. Even f() is, in today's standards, an invalid construct since the lack of a return type defaults to an integer, and there is no return value in the function. So, this is totally bogus and I have said enough. P.S. I teach advanced C and C++ programming to software engineers.


i thot tht ws quite implicit wat u said...
newez sry fr nt putting it correclty...
my doubt is simply whther is it necessary to perform d above typecast???

Votes + Comments
Speak in full sentence English, please. That was part of the reason for the -1 before.

wat is d need to typecast..??/

First and foremost, function pointers and object pointers are incompatible with or without a cast. This cast is a very bad idea, and your book is likely written by an idiot unless it's showing how not to do things. To answer your question, the cast is required to compile because there's no implicit conversion from the function pointer type to int*.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.