delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/05/30/23:28:19

From: "Jason" <jr_4226 AT yahoo DOT com>
Newsgroups: comp.os.msdos.djgpp
References: <3cf6c05e_1 AT news DOT iprimus DOT com DOT au>
Subject: Re: Vector of Classes issue in GCC 3.1
Lines: 40
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
X-Original-NNTP-Posting-Host: 203.134.47.138
Message-ID: <3cf6d9d1$1_1@news.iprimus.com.au>
X-Original-NNTP-Posting-Host: 127.0.0.1
Organization: iPrimus Customer - reports relating to abuse should be sent to abuse AT iprimus DOT com DOT au
Date: Fri, 31 May 2002 02:02:01 GMT
NNTP-Posting-Host: 203.134.67.67
X-Complaints-To: news AT primus DOT ca
X-Trace: news.tor.primus.ca 1022810521 203.134.67.67 (Thu, 30 May 2002 22:02:01 EDT)
NNTP-Posting-Date: Thu, 30 May 2002 22:02:01 EDT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

As a followup, I have traced the problem back to the CBoard instance calling
the destructor straight after calling the constructor, upon 'push'ing CBoard
onto the vector container.  This means that my 'new'ly created BoardSpace is
'delete'd.  Is this C++ standard behaviour?  If so, how do I get around
that?

Jase.

"Jason" <jr_4226 AT yahoo DOT com> wrote in message
news:3cf6c05e_1 AT news DOT iprimus DOT com DOT au...
> Hi All,
>
>   I have been working on a piece of test code that makes a vector of
> classes.  If I make one instance of the class outside of the vector (as a
> normal class instance) the program works fine.  However, when I access
> member functions from the class inside the vector container, I get wierd
> memory corruptions!
>
>   The code is attached (I hope this is OK - it is just a few small text
> files) in the hope that others may be able to reproduce the results.
> connect4.cpp is the main function, board.cpp/h are the CBoard class
> specifier & implementation.
>
>   BTW, the code is for a simple four-in-a-row game.  The first round of
the
> game works fine, but consecutive rounds seem to stuff up the board!  I
have
> successfully compiled and run this code using DevC++ in it's current
state -
> no wierdness.
>
>   Thanks in advance,
>
>   Jase.
>
>
>
>


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019