| View previous topic :: View next topic |
| Author |
Message |
TheWarman Guest
|
Posted: Fri Oct 15, 2004 11:02 pm Post subject: STL iterator::operator== error question |
|
|
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
|
Posted: Sat Oct 16, 2004 10:20 am Post subject: Re: STL iterator::operator== error question |
|
|
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
|
Posted: Sun Oct 17, 2004 1:28 am Post subject: Re: STL iterator::operator== error question |
|
|
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
|
Posted: Mon Oct 18, 2004 4:40 pm Post subject: Re: STL iterator::operator== error question |
|
|
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 |
|
 |
|