Mail Archives: djgpp/1997/09/21/20:46:33
Newsgroups: | comp.os.msdos.djgpp
|
From: | Sam Davies <sdavies AT unix DOT trilogy DOT net>
|
Subject: | Help! Variable allocation!
|
Message-ID: | <EGvsMu.FCt@nonexistent.com>
|
Mime-Version: | 1.0
|
Date: | Sun, 21 Sep 1997 23:17:08 GMT
|
Lines: | 25
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Hi! I'm new to DJGPP, but for some reason, a piece of code that I wrote
doesn't seem to run correctly. Here it is:
polygon polygon::operator =(const polygon &src)
{
if(nv) delete vlist;
nv = src.nv;
vlist = new point[nv]*;
for(int i=0;i<nv;i++)
vlist[i]=src.vlist[i];
return *this;
}
Ok, now I'm using this operator to initialize each member of an array of
polygons, but for some reason the new operator on the "vlist =..." line
seems to be giving me the same address every time. The result is that
the array of points (vlist) for each polygon is overlapping in memory!
Is this my own bug? Or one with DJGPP? Or did I forget a compiler
option? Do you need more source code?
Any help you can give is *much* appreciated! :)
Sam
--
Sam Davies <sdavies AT mail DOT trilogy DOT net>
- Raw text -