473,396 Members | 1,892 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.

[Project] List & ConstIterator

I have the following class:

<CODE>

class List
{
public:

class Node
{
public:
Node* m_next;
};

class Iterator
{
public:
Node *m_position;
};

class ConstIterator
{
public:
ConstIterator( Node* pos );
Node *m_position;
};

// utility functions
ConstIterator begin() const;
Iterator begin();

// data members
Node* m_head;

};

</CODE>

The problematic implementation of const begin is:

<CODE>

List::ConstIterator
List::begin() const
{
return List::ConstIterator(m_head);
}

</CODE>

This is wrong because it is impossible to convert const List::m_head to just
pointer. My question is how to project class List to use Iterator and
ConstIterator functionality? I know I can use const_cast to remove constant
property from const List::m_head pointer but I think this isn't a good idea.

Thanks

Nov 15 '05 #1
3 1896

Try a C++ newsgroup.
Igmar
Nov 15 '05 #2
hokus wrote:
I have the following class:

<CODE>

class List
{
public:


[etc.]
If you have a question about C++, ask in <news:comp.lang.c++>. In
<news:comp.lang.c> questions about such a byzantine language are frowned
on and not answered. If someone should post an answer, treat it with
all the respect you would give an answer from an APL, LISP, Fortran, or
Forth programmer about C++; that is to say, none.
Nov 15 '05 #3
hokus wrote on 29/09/05 :
I have the following class:


Try a Pascal news group... (but avoid a C++ news group, it would be too
easy...)

--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html

I once asked an expert COBOL programmer, how to
declare local variables in COBOL, the reply was:
"what is a local variable?"
Nov 15 '05 #4

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

Similar topics

4
by: Ville Vainio | last post by:
I am thinking of implementing a nice little source code generation program with empy. I'm planning on having one directory with arbitrary number of templates. Templates can contain a significator...
4
by: hokus | last post by:
I have the following class: <CODE> class List { public: class Node {
2
by: Matthew Wieder | last post by:
In my previous post, I asked about a routine which prepares a string for an XPath query by taking care of escape characters. Unable to find a list, I'm now wondering assumign I enclose the...
13
by: Ilias Lazaridis | last post by:
I have implemented a simple schema evolution support for django, due to a need for a personal project. Additionally, I've provided an Audit: http://case.lazaridis.com/wiki/DjangoAudit As a...
0
by: weiwei | last post by:
Hi here is my scenario, I create a drop down list in itemtemplate.(that drop down is created from db), after user click edit command, my ideal plan is have another drop down list in...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
2
by: smartic | last post by:
i'm having three lists when i select from any one the others be visible by hierarchy but it takes to long to write my code is there is another away to write this code like XML that is my javascript...
5
by: googletired | last post by:
On my current site, I can click on a category and the view the content of that category. This is fine, but now I want to be able to view the contents of *ALL* the categories in one continous scroll...
4
MMcCarthy
by: MMcCarthy | last post by:
http://bytes.com/images/howtos/projectscope_blocks.jpgAs a freelance IT consultant for over 10 years, I’ve come to appreciate well defined project scopes. A project scope is a common understanding...
1
RRick
by: RRick | last post by:
I have a unix C++ project that needs to be converted over to windows visual studio. I'm not sure of the exact version of VS, but it's a recent version, probabIy 2003 or 2005. I would like the...
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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
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.