I have function declaration as below
void func1(const void& * pThis) {
MyClass* pMyClass = static_cast<MyClass*>(pThis); //....I use PMyClass pointer.
}
I am getting error cannot convert const void* to MyClass*
How to do this step?
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.
You can
But this awful syntax is the hint: why then the function has a const argument, wouldn’t you want it to be like
Of course, you can take a shortcut using C-style cast:
but I would fix the design instead if possible.