Casting const void* to const int*
问题 I haven't used void* and const_correctness before so I am not understanding what I am doing wrong in the below code. All I want is to cast a void* returned by a member function of a const object to int*. Please suggest better approaches. Thank you. I get the following error passing 'const MyClass' as 'this' argument of 'void* MyClass::getArr()' discards qualifiers So here's the actual program that I had problem with class MyClassImpl{ CvMat* arr; public: MyClassImpl(){arr = new CvMat[10];}