Skip to main content
gamedev.net
🔒 Locked

managed C++ array

Started by a2ps Jan 2, 2004 at 7:21 PM 3 replies 1.2k views
Original Post
a2ps
a2ps
hi there, im having problems on making an array of buttons: i have the following class: __gc class foo : public Form{ private: Button *scope[]; ... //constructor: foo::foo{ this->scope = new Button *[300]; for( int i = 0; i < 300; i++ ){ this->scope->Location = System::Drawing:oint( i, 200 ); this->scope[i]->Width = 1; this->scope[i]->Height = 1; this->scope[i]->BackColor = System::Drawing::Color::DarkRed; this->Controls->Add( this->scope[i] ); } } this does compile but when running it it crashes and gives me the error: "System.NullReferenceException: object reference not set to an instance of an object". is there anyway i can correct this? thanks. [edited by - a2ps on January 2, 2004 8:32:02 PM]
yet, another stupid signature..
a2ps
a2ps
you know those type of replies arent really necessary..

and since youre so smart, i dont you just help me out?

btw, the ['i'] on scope->set_Location doesnt appear, dont know why, but it is there.

[edited by - a2ps on January 2, 2004 8:34:46 PM]
yet, another stupid signature..
VolkerG
VolkerG
You have to create an instance of the button using new.
Like

this->scope[i] = new Button ()


[edited by - VolkerG on January 2, 2004 8:37:06 PM]
a2ps
a2ps

it is : : P but the forum just makes it a smile...
yet, another stupid signature..

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.