Intellisense shows that message when you are calling a non-const
function on an object that is const
. As we can see, ReturnPtr
is non-const. There are generally two reasons you might see this message. The first is when you are trying to call ReturnPtr
on a const
object of type BufferWrapper
:
const BufferWrapper bw;
bw.ReturnPtr(); // Can't call non-const member function on const object
The second is when your BufferWrapper
object is a data member of a class and you are calling ReturnPtr
on it from within a const
member function of that class:
struct SomeClass
{
BufferWrapper bw;
void SomeClass::SomeFunc() const
{
bw.ReturnPtr(); // Cannot call non-const member function here
}
}