Switch to full style
For C/C++ coders discussions and solutions
Post a reply

Safe Programming

Sat Nov 29, 2008 12:58 am

One of code steps you do in your C coding with pointers , is to to check on the pointer before you use it ( just to be in safe )

for example :
Code:
    MyClass *mypointer=new MyClass(param1,param2...) ;
    *mypointer->function();

what will happen if the "mypointer" not allocated ,null pointer error .to avoid this .
Code:
    MyClass *mypointer=new MyClass(param1,param2...) ;
      if(mypointer !=NULL )
    *mypointer->function();
   



You will avoid these errors , just by this small check , higher level like Java contain no pointers .In fact this is one of power stands in Java .So you don't need to take care about this there . It can be caught easy as exception.



Post a reply
  Related Posts  to : Safe Programming
 Thread Safe     -  
 ALP programming     -  
 C++ programming     -  
 i want some help in java programming     -  
 Java Programming help please?     -  
 Different Styles of Programming     -  
 Programming.PHP.2nd.Edition.zip     -  
 Suggest course for programming     -  
 javascript programming     -  
 c++ general programming     -