I have a function which returns a pointer and this works fine. I now have another function that I want to return a const pointer. How can I convert my pointer to a const pointer?
I have tried
Object* constObjectPointer = workingPointer;
however this doesnt work, I need the const pointer output to return from this function.
It does not matter whether 'ptr' is to const or non-const object for the latter function. The function returns a copy of the value of ptr (an address) as a pointer to constant type Object object.
class Foo {
T
funbar() const // if you have a const member function
{
this->sob(); // that calls other member
}
// then the called member
U
sob() const // has to be const too
{
}
};