#include <iostream>
int main()
{
int a = 5;
int b = 10;
void *p = reinterpret_cast<void*>(a * B)>;
int result = *reinterpret_cast<int*>(&p);
std::cout << std::endl << result << std::endl;
return 0;
}
I want to know whether this is considered a safe operation, and why it works.
What is the pointer p pointing at, and why do I have to take the address of the pointer before I can dereference it?
As a follow-up I'm interested by the implications of a similar method in terms of function pointers, but first I need to understand what's happening here, whether it's safe, portable, etc.
Edit: I'm trying to get rid of a superfluous "/>", but it doesn't seem to be working... ://>/>
This post has been edited by GunnerInc: 31 December 2012 - 07:25 PM
Reason for edit:: Fixed superfluous "/>"

New Topic/Question
Reply




MultiQuote








|