hello allCode:using namespace std; #include <cstring> #include <iostream> #include <cstdlib> int main(){ IntPtr p; }
in the book it says it is legal to create a pointer with "IntPtr" but in this code it gave me error ? anybodey help me ?
hello allCode:using namespace std; #include <cstring> #include <iostream> #include <cstdlib> int main(){ IntPtr p; }
in the book it says it is legal to create a pointer with "IntPtr" but in this code it gave me error ? anybodey help me ?
I presume that by "the book" you mean Jumping into C++, which happens to have been authored by the webmaster of this website and forum community. As such, I shall move this topic to the C++ programming forum.Originally Posted by uryenugurkem
It is legal to do so if you have a typedef for the name IntPtr. Without such a typedef, the name IntPtr is undefined, so you would be unable to do so.Originally Posted by uryenugurkem
By the way, the using namespace std; using directive should be placed after the last header inclusion. Placing it before a header inclusion affects the content of the header, which can be a Bad Thing.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
I don't think a type IntPtr is defined in the headers you included, so the compiler doesn't know about it.
There might be a custom header supplied with the book you're using that defines this type.
If you include cstdint, you could use intptr_t but I think you should stick to declaring pointers the usual way unless you have a specific reason.
(laserlight beat me to it, I'll just leave my reply )