C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

STL iterator::operator== error question

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
TheWarman
Guest





PostPosted: Fri Oct 15, 2004 11:02 pm    Post subject: STL iterator::operator== error question Reply with quote



I am getting a SIGSEGV error and wondered if anyone could help me out.

I am creating a double ended queue and a corresponding iterator using
a pointer to a double as a member of a C++ class object I call class
SObject.

class SObject
{
public:
SObject();
~SObject();

deque<double*> theDEQ;
deque<double*>::iterator theDEQItr;
}

Declaring the SObject:

SOBject* mySObjPtr;

During runtime I use the "new" operator to create an instance of
SObject and I get a SIGSEGV on deque::iterator::operator==()

mySObjPtr = new SObject();


Anyone know why? STL has never given me problems before.

I'm on an SGI running IRIX and the error is in a file (if I remember
right) /usr/CC/include/stl_deque.h

All comments appreciated - Thanks.

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Markus Moll
Guest





PostPosted: Sat Oct 16, 2004 10:20 am    Post subject: Re: STL iterator::operator== error question Reply with quote



Hi

TheWarman wrote:

Quote:
During runtime I use the "new" operator to create an instance of
SObject and I get a SIGSEGV on deque::iterator::operator==()

mySObjPtr = new SObject();


Anyone know why? STL has never given me problems before.

What does your constructor look like?

Markus

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Frank
Guest





PostPosted: Sun Oct 17, 2004 1:28 am    Post subject: Re: STL iterator::operator== error question Reply with quote




Hi,
you should probably post the code, where you try to use the iterator.
I would guess that you are using an invalid pointer in the deque.

Cheers
Frank


TheWarman wrote:

Quote:
I am getting a SIGSEGV error and wondered if anyone could help me out.

I am creating a double ended queue and a corresponding iterator using
a pointer to a double as a member of a C++ class object I call class
SObject.

class SObject
{
public:
SObject();
~SObject();

deque<double*> theDEQ;
deque<double*>::iterator theDEQItr; }

Declaring the SObject:

SOBject* mySObjPtr;

During runtime I use the "new" operator to create an instance of
SObject and I get a SIGSEGV on deque::iterator::operator==()

mySObjPtr = new SObject();


Anyone know why? STL has never given me problems before.

I'm on an SGI running IRIX and the error is in a file (if I remember
right) /usr/CC/include/stl_deque.h

All comments appreciated - Thanks.

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


Back to top
Ulrich Eckhardt
Guest





PostPosted: Mon Oct 18, 2004 4:40 pm    Post subject: Re: STL iterator::operator== error question Reply with quote

TheWarman wrote:
Quote:
I am getting a SIGSEGV error and wondered if anyone could help me out.

I am creating a double ended queue and a corresponding iterator using
a pointer to a double as a member of a C++ class object I call class
SObject.

class SObject
{
public:
SObject();
~SObject();

deque<double*> theDEQ;
deque<double*>::iterator theDEQItr;
}

Let's ignore the fact that this declaration lacks a trailing semicolon, it
is also probably broken in other aspects. The reason is that you have an
object-type that contains pointers(indirectly via 'theDEQ') but doesn't
have a proper copy constructor and assignment operator. Also, assuming
'theDEQItr' points to somewhere inside the deque, copying it will be
disastrous, as the copy still points to the original SObject's deque.

Note however that all of the above might be void - since you basically
didn't show any example of how it is supposed to be used, I can only guess
what can go wrong with this.

Quote:
Declaring the SObject:

SOBject* mySObjPtr;

During runtime I use the "new" operator to create an instance of
SObject and I get a SIGSEGV on deque::iterator::operator==()

mySObjPtr = new SObject();

Perchance you have a strong Java background? If so, don't try to write Java
programs in C++, get a good book[1] to help you in that task.

Uli


[1] http://accu.org

--
Questions ?
see C++-FAQ Lite: http://parashift.com/c++-faq-lite/ first !


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.