call non-const function



 DEVELOP > c-Plus-Plus > call non-const function

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "Gernot Frisch"
Date: 09 Feb 2005 09:24:44 AM
Object: call non-const function
GFXMLTree* Seek4Node(LPCTSTR name);
const GFXMLTree* Seek4Node(LPCTSTR name) const
{
return Seek4Node(name); // Force to call the first version
}
--
-Gernot
int main(int argc, char** argv) {printf
("%silto%c%cf%cgl%ssic%ccom%c", "ma", 58, 'g', 64, "ba", 46, 10);}
.

User: "Victor Bazarov"

Title: Re: call non-const function 09 Feb 2005 09:40:52 AM
Gernot Frisch wrote:

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
.


  Page 1 of 1

1

 


Related Articles
call const function from non const function
illegal call of non-static member function [why???]
non-virtual call to a virtual function using pointer to member
parse error in gcc but success in vc.net, call a non_template class's template member function from a template class's member function!
How to call a non static function from a static function
How to add and call a do-nothing non-default constructor?
non-POD type in call to va_start
illegal call of non-static member compile error question
Picking const vs. non-const member functions upon a call
Re: Detecting static or non-static member function?
link error if template function is defined in non-header file
[Q] Pointers to Non-Static class member functions
Function pointer member variable to non-member function
Pointers to non-static member functions, compiles with MSDEV, but not with GCC
non-repeating numbs
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER