how can I convert any object of my own class convert into pointer to void?
MyClass obj;
(void*)obj; // Fail
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
But beware !
objis allocated on the stack this way, as soon as you leave the function the pointer becomes invalid.Edit: Updated to show that in this case an explicit cast is not necessary since every pointer is compatible with a void pointer.