Is it possible to cast from a predefined Type_pointer in c++ to its Type?
For example we defined a custom XType.
I want to do something like this, but I get an error:
XType* b;
XType a = (XType) b;
I want to pass the pointer itself to a function that only accept Type (not Type*)
In addition to the @Robᵩ’s proposal, you can change the function to accept the pointer.
Actually, if you plan to pass the pointer to other functions from within the given function, you must get the pointer (well, or a reference) as parameter, otherwise you’ll get a copy of the original object as the parameter, so you’ll be unable to retrieve the address of (i.e. pointer to) the original object.
If you’d like to spare the refactoring, you can do the reference trick: