call non-const function

G

Gernot Frisch

GFXMLTree* Seek4Node(LPCTSTR name);
const GFXMLTree* Seek4Node(LPCTSTR name) const
{
return Seek4Node(name); // Force to call the first version
}
 
V

Victor Bazarov

Gernot said:
GFXMLTree* Seek4Node(LPCTSTR name);
const GFXMLTree* Seek4Node(LPCTSTR name) const
{
return Seek4Node(name); // Force to call the first version
}

You can only safely do that if you know that your object was in fact
non-const when it was created. But that's only known by the caller,
not inside the function. So, before calling the overloaded member
function, cast the constness away.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,201
Messages
2,571,049
Members
47,653
Latest member
YvonneJif

Latest Threads

Top