473,406 Members | 2,619 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,406 software developers and data experts.

Question on Lists and Classes.

All,

I would appreciate if someone can help me with this. Never used STL
containers extensively, but facing this issue now.

I have a Class A, which has a bunch of member variables and functios.

I have a Class B, which has its own memmber variables, one of them
being a

list <Class A> a;

so if I need to access the List through the member functions of Class
B, like say while using an Iterator...do I need to overlad the
iterator? Since the list isnt standard data-types, is there a need to
overload the iterator ? I didnt think so, but I am getting some errors
while compiling, when I

list<A>::iterator iter(a);

for( iter = iter.begin(), !iter, iter++
{
}

The error(s) being C2264 and c2039(BEGIN NOT MEMBER OF ITERATOR)

Because in the same problem I have used the iterator on a list of
integers and obviously no problem there.

Thanks.
Jul 22 '05 #1
3 1138
virenpratapsingh wrote:
All,

I would appreciate if someone can help me with this. Never used STL
containers extensively, but facing this issue now.
[...]


The problems you're having is due to your poor knowledge of how
to use the containers. It is easily cured by a good book. Please
find one and read it.

A quick hint: iterators iterate, they don't begin, the containers
begin and end. To get the beginning of a container call 'begin'
for that container, not for the iterator.

V
Jul 22 '05 #2
virenpratapsingh wrote:
All,

I would appreciate if someone can help me with this. Never used STL
containers extensively, but facing this issue now.

I have a Class A, which has a bunch of member variables and functios.

I have a Class B, which has its own memmber variables, one of them
being a

list <Class A> a;

so if I need to access the List through the member functions of Class
B, like say while using an Iterator...do I need to overlad the
iterator? Since the list isnt standard data-types, is there a need to
overload the iterator ? I didnt think so, but I am getting some errors
while compiling, when I

list<A>::iterator iter(a);

for( iter = iter.begin(), !iter, iter++
{
}
Ths small piece of code has about half a dozen errors. It's not
surprising that it doesn't work. If that's not the actual code you
tried, then show the actual code. A small, but complete C++ program
that shows the problem you observed.
The error(s) being C2264 and c2039(BEGIN NOT MEMBER OF ITERATOR)
There is neither something with the name ITERATOR, nor BEGIN. Maybe this
isn't the original error message and you actually meant iterator and
begin? In this case, the compiler is right. Iterators don't have a
member begin(). The containers have one, though.
Because in the same problem I have used the iterator on a list of
integers and obviously no problem there.


I guess you have used it differently then.
Jul 22 '05 #3
an******@yahoo.com (virenpratapsingh) wrote:
I would appreciate if someone can help me with this.
[snip]
so if I need to access the List through the member functions of Class
B, like say while using an Iterator...do I need to overlad the
iterator?
No.
Since the list isnt standard data-types, is there a need to
overload the iterator ?
No.
list<A>::iterator iter(a);

for( iter = iter.begin(), !iter, iter++
{
}

The error(s) being C2264 and c2039(BEGIN NOT MEMBER OF ITERATOR)

Because in the same problem I have used the iterator on a list of
integers and obviously no problem there.


Could you show us the code where you iterate over a list of integers
please? Maybe there is a difference between them...

You might also want to read:
<http://www.sgi.com/tech/stl/>
Jul 22 '05 #4

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

Similar topics

5
by: Hal Vaughan | last post by:
I think a lot of this is definately a question of personal programming style, but I'm new to Java and would like to hear a few opinions. I'm writing a control panel for an application that runs...
2
by: Kakarot | last post by:
I'm gona be very honest here, I suck at programming, *especially* at C++. It's funny because I actually like the idea of programming ... normally what I like I'm atleast decent at. But C++ is a...
9
by: Dave H | last post by:
Hello, I have a query regarding definition lists. Is it good practice semantically to use the dt and dd elements to mark up questions and answers in a frequently asked questions list, or FAQ? ...
5
by: Roger Bonine | last post by:
I'm working on a rewrite of our employee database. I plan to implement a fairly heavyweight base class, which includes 20 or 30 fields, including address and phone number collections and the like....
10
by: JustSomeGuy | last post by:
I have a few classes... class a : std::list<baseclass> { int keya; }; class b : std::list<a> { int keyb;
3
by: Claudio Grondi | last post by:
Trying to understand the outcome of the recent thread (called later reference thread): "Speed quirk: redundant line gives six-fold speedup" I have put following piece of Python code together:...
105
by: Christoph Zwerschke | last post by:
Sometimes I find myself stumbling over Python issues which have to do with what I perceive as a lack of orthogonality. For instance, I just wanted to use the index() method on a tuple which does...
90
by: John Salerno | last post by:
I'm a little confused. Why doesn't s evaluate to True in the first part, but it does in the second? Is the first statement something different? False print 'hi' hi Thanks.
11
by: manstey | last post by:
Hi, I am having trouble designing my classes. I have two classes. The first one wraps around an old-style class called oref Class CacheClass(object): def __init__(self, obj):
4
by: wageslave | last post by:
Hi folks, I have a question about using consequtive combo boxes on a form. I am designing a basic library database for a small community organisation which deals with inner city problems and...
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: 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...
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
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
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.