473,396 Members | 1,866 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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);}
Jul 23 '05 #1
1 1557
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
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: MPOOL'03 Organizers | last post by:
We apologize if you receive this CfP multiple times * Please distribute ! -------------------------------------------------------------------------- CALL FOR PAPERS Workshop on ...
0
by: MPOOL'03 Organizers | last post by:
We apologize if you receive this CfP multiple times * Please distribute ! -------------------------------------------------------------------------- CALL FOR PAPERS Workshop on ...
13
by: Mike Qin | last post by:
Hi there, Now I'm writing code mainly in C++. And some existing c code will call some functions which are in a C++ class. I read the basic techniques introduced from a SUN's web site. Basically...
0
by: Jörg Striegnitz | last post by:
We apologize if you have received this CfP multiple times. -------------------------------------------------------------------- SECOND CALL FOR CONTRIBUTIONS AND PARTICIPATION Workshop on...
8
by: ThomasR | last post by:
I understand that virtual methods on inherited objects are slower than non-virtual methods because of the indirection required to support the call. However, when looking at IL code produced by...
5
by: Ross | last post by:
Hi, I have the following program: #include <stdarg.h> class A { public: A() { } }
46
by: Steven T. Hatton | last post by:
I just read §2.11.3 of D&E, and I have to say, I'm quite puzzled by what it says. http://java.sun.com/docs/books/tutorial/essential/concurrency/syncrgb.html <shrug> -- NOUN:1. Money or...
1
by: Ken Williams | last post by:
Assume I have two Forms Form1.cs and Form2.cs. When a button but1-switch is clicked on Form1.ca the second Form2.cs should be called and displayed. How do I call the second Form2.cs in modal...
3
by: Kevin Walzer | last post by:
I'm currently using os.popen in an application of mine, which calls for non-blocking data, in this fashion: self.file = os.popen('echo %s | sudo -S /sw/bin/fink -y install %s' % (self.passtext,...
12
by: puzzlecracker | last post by:
is it even possible or/and there is a better alternative to accept input in a nonblocking manner?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.