you didn''t copy his code right:
Clock clock[] = new Clock[7];
NOT
Clock clock = new Clock[7];
-me
How Do I Create Multiple Objects Without Declaring Them, With A Loop?
hah thanks. I just jump the gun all the time when I am into something Thanks For all the help.
quote:Original post by Anonymous Poster
Clock ** clocks
clocks = new (Clock *)[7];
for(i=0;i<7;++i)
clocks = new Clock();
This is so ugly, why a double pointer, newing an array with a cast etc ?
A class is stored as a pointer anyway, so why this indirection ? Why not just
Clock clocks[7];
for(i=0;i<7;i++) {
clocks = new Clock();<br>} </i>
quote:Original post by Fidelio66
This is so ugly, why a double pointer, newing an array with a cast etc ?
A class is stored as a pointer anyway, so why this indirection ? Why not just
Clock clocks[7];
for(i=0;i<7;i++) {
clocks = new Clock();
}
Ugly? UGLY?! Well, how about THIS!
void DoStuffL(){ RPointerArray< Clock > iClocks; for ( TInt i = 0; i < 7; ++i ) { Clock *iClock = Clock::NewL(); CleanupStack:: Push( iClock ); iClocks.Append( iClock ); } for ( TInt i = 0; i < 7; ++i ) CleanupStack:: Pop();}
(I'm sure someone who actually knows symbian can point out quite a few mistakes with that code. And I thought microsoft's code looked bad..)
[edited by - Painless on March 24, 2004 7:06:37 PM]
Why can't you just do
Clock clocks[7]?
Oh, you have a non-trivial ctor, that's why. Evil, pure evil.
[edited by - Magmai Kai Holmlor on March 24, 2004 8:59:15 PM]
Clock clocks[7]?
Oh, you have a non-trivial ctor, that's why. Evil, pure evil.
[edited by - Magmai Kai Holmlor on March 24, 2004 8:59:15 PM]
quote:
Ugly? UGLY?! Well, how about THIS!void DoStuffL()
{snip}
You want the stability, you gotta pay the price....
[edited by - shmoove on March 25, 2004 4:22:59 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement