473,394 Members | 1,843 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,394 software developers and data experts.

how to make current member-function const: a problem

6
good day.

suppose i have:
Expand|Select|Wrap|Line Numbers
  1. class Key;
  2. class Value;
  3. class CList : public boost::enable_shared_from_this<CList>
  4. {
  5.   std::map<Key, Value> _data;
  6.   std::shared_ptr<CList> _pParentPtr;
  7. public:
  8.     //...
  9.     bool hasKey(const Key &key) const;
  10.     std::shared_ptr<CList> getParent() const{
  11.         return _pParentPtr;
  12.     }
  13. };
  14.  
  15. bool CList::hasKey(const Key &key) {
  16.     boost::shared_ptr<CList> pCurList(shared_from_this()); //!
  17.  
  18.     bool res = false;
  19.     do{
  20.         res = _data.find(key) != data.end();
  21.         pCurList = pCurList->getParent();
  22.     } while (!res && pCurList);
  23.  
  24.    return res;
  25. }
  26.  
how can i make CList::hasKey(const Key &key) const ?
thanks for clarifications.
Jun 28 '08 #1
1 1077
varnie
6
i figured it out. here's solution:
Expand|Select|Wrap|Line Numbers
  1. bool CList::hasKey(const Key &key) const {
  2.     boost::shared_ptr<CList const> pCurList(shared_from_this()); 
  3.     bool res = false;
  4.     do{
  5.         res = _data.find(key) != data.end();
  6.         pCurList = pCurList->getParent();
  7.     } while (!res && pCurList);
  8.    return res;
  9. }
  10.  
Jun 29 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Steven T. Hatton | last post by:
This is something I've been looking at because it is central to a currently broken part of the KDevelop new application wizard. I'm not complaining about it being broken, It's a CVS images. ...
5
by: Denis Perelyubskiy | last post by:
Hello, I need to make an array of elements accross forms. My javascript skills, as evident from this question, are rather rudimentary. I tried to make an associative array and index it with...
1
by: Brendan Ganning | last post by:
I am trying to select all the chapters from the chapter table, and then for each chapter instert a count of how many members are in that chapter into another table.. Here is the code so far and I...
9
by: Sasha | last post by:
Hi, I am extending standard IEnumerator, and I was just wondering what is the best way to make enumarator safe? What do I mean by safe? Detect deletes and all... My idea is to have private Guid...
6
by: Tiraman | last post by:
Hi, in vb6 we could use the GetObjectContext("Request") of the ASPTypeLibrary.Request in order to get the ServerVariables("XXX") from the asp to the dll . can we do that in aspx and vb dot...
0
by: Ben | last post by:
module main ... application.run(new splashform) .. end module after a few screen, I try to load a new codes I got from MSDN on datagrid that works on its own. I took out submain and ran...
18
by: smnoff | last post by:
Ok, I am think I am a little more knowledgeable about C and pointers, ughh. And likewise, I want to fix C.....and not so much to make a C++ or Java or C# or even D like language. So, if I...
3
by: namewitheldbyrequest | last post by:
"The XML element 'EnableTheming' from namespace 'http://tempuri.org/' is already present in the current scope" I created a Web Service: I imported System.Data.SqlClient so I could access SQL...
0
by: MS Development | last post by:
Hello Newgroup, I'm new to ASP.NET and its nice navigation features. I have now some problems with them which I hope can anyone solve. So here we go: The generel idea is I have a page like e....
5
by: Torsten Bronger | last post by:
Hallöchen! How can I get a list with all classes defined in the current module? Thank you! Tschö, Torsten. -- Torsten Bronger, aquisgrana, europa vetus
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.