Thread overview
Strange Problem with class
Sep 22, 2002
Robert M. Münch
Sep 22, 2002
Patrick Down
Sep 25, 2002
Robert M. Münch
Sep 22, 2002
Burton Radons
September 22, 2002
Hi, I have the following code that will get my CPU usage to 100% and never terminates:

import stdio;

class bo_template {
int name = 1;
}

int main ()
{
bo_template bo_test;
printf("%d\n", bo_test.name);
return 0;
}


Any idea, what the problem is?

--
Robert M. Münch
IT & Management Freelancer
Mobile: +49 (0)177 2452 802
Fax   : +49 (0)721 8408 9112
Web   : http://www.robertmuench.de



September 22, 2002
"Robert M. Münch" <robert.muench@robertmuench.de> wrote in news:amkm3c$1vdh$1@digitaldaemon.com:

> Hi, I have the following code that will get my CPU usage to 100% and never terminates:
> 
> import stdio;
> 
> class bo_template {
> int name = 1;
> }
> 
> int main ()
> {
> bo_template bo_test;
> printf("%d\n", bo_test.name);
> return 0;
> }
> 
> 
> Any idea, what the problem is?

Yes, bo_test is not initialized.
You need...

bo_test = new bp_template();

It seems that in the Windows version of DMD a null object reference seems to go off into la la land.
September 22, 2002
Robert M. Münch wrote:
> Hi, I have the following code that will get my CPU usage to 100% and never
> terminates:
> 
> import stdio;
> 
> class bo_template {
> int name = 1;
> }
> 
> int main ()
> {
> bo_template bo_test;
> printf("%d\n", bo_test.name);
> return 0;
> }

bo_test is pointing to null here.

September 25, 2002
"Patrick Down" <pat@codemoon.com> schrieb im Newsbeitrag news:Xns92917C401B5E1patcodemooncom@63.105.9.61...

> Yes, bo_test is not initialized.
> You need...
>
> bo_test = new bp_template();

Hi, :-| mea culpa. Of course this should be done. I'm programming with to much scripting languages where you just mention objects an get them.

> It seems that in the Windows version of
> DMD a null object reference seems to go
> off into la la land.

Yes, that's the case. It should give a runtime error because of 0-object reference usage. Robert