How to const declare the this pointer sent as parameter
Posted
by Tomas
on Stack Overflow
See other posts from Stack Overflow
or by Tomas
Published on 2010-06-15T08:17:31Z
Indexed on
2010/06/15
8:22 UTC
Read the original article
Hit count: 215
Hi,
I want to const declare the this pointer received as an argument.
static void Class::func(const OtherClass *otherClass)
{
// use otherClass pointer to read, but not write to it.
}
It is being called like this:
void OtherClass::func()
{
Class::func(this);
}
This does not compile nad if i dont const declare the OtherClass pointer, I can change it.
Thanks.
© Stack Overflow or respective owner