Top.Mail.Ru
The C++ Community's Journal -- Day
? ?
The C++ Community's Journal -- Day [entries|friends|calendar]
The C++ Community

[ userinfo | livejournal userinfo ]
[ calendar | livejournal calendar ]

C++ storing objects in an array [03 Jan 2009|11:19pm]
Hey all,

Got a simple question but I can't seem to get this right. I'm trying to created a two dimensional array of type Base and I"m trying to store objects derived from base in there But I keep getting this error message:

no match for ‘operator=’ in ‘*((*(((Base**)(((unsigned int)x) * 4u)) + t)) + ((Base*)(((unsigned int)y) * 16u))) = (((ObjectDerivedFromBase*)operator new(20u)), (->ObjectDerivedFromBase::(ObjectDerivedFromBase), ))’
Base.h:6: note: candidates are: Base& Base::operator=(const Base&)

I'm confused, I'm not trying to operator overload anything...

Thanks for any comments!



int ROW = 5;
int COLUMN = 5;
Base **t = new Base*[ROW];

for(int x = 0; x < ROW; ++x)
{
*(t+ x) = new Base[COLUMN];
}

for(int x = 0; x < ROW; ++x)
{
for(int y = 0; y < COLUMN; ++y)
{
t[x][y] = new ObjectDerivedFromBase(); // WHY WONT THIS LINE WORK?????
}
}
14 comments|post comment

navigation
[ viewing | January 3rd, 2009 ]
[ go | previous day|next day ]
Image