Click to See Complete Forum and Search --> : Allocator problem


PeiFeng
April 20th, 2003, 01:47 AM
In my API program,I try to include file <list>, save data
in a list called CShapeArray.

However,everytime when I create a new object and assign its
adddress to a pointer called nShape,and then insert the object to the end of CShapeArray. I always get the same address and create the object in the same address.So the list CShapeArray is full of same objects.

what should I do ? Is there any way to create different object
int different address?

Here is some reference code: help
..........
#include <list>
#include "CShape.h"

using namespace std;

typedef list<CShape> CShapeList;

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static CShapeList m_ShapeArray;
static CShape* nShape;
CShapeList::iterator it;
.............
switch (message)
{
case WM_LBUTTONUP:
nShape=new CShape(.......); //create object in same address
m_ShapeArray.insert(m_ShapeArray.end(),*nShape);
nShape=NULL;
...................