PDA

View Full Version : Is there any way to avoid the use of a class not created.



tonnot
28th June 2011, 13:49
I have a class, in example, Myclass.
I create an instance of it, in example, myclass;

Sometimes I use, by mistake, Myclass.my_property. (uppercase)
Ok, I can compile and run my program, but the value returned are wrong (and can do my program crash ).

Can I solve this ? That is to say, how to avoid the use of classes not instanciated ?
Thanks

Ups, please move to general programming.

Rachol
28th June 2011, 14:04
I can't get what you mean but do not have public member variables, use getters and setters. Another thing is that you can have all the needed parameters in the constructor, that cannot be instanciated without passing correct values.

FelixB
28th June 2011, 14:09
don't use a variable name that is almost like the class name