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     -  
 c++ general programming     -  
 hello pls i want the codens in c# programming     -  
 why to use scanf in c programming     -  
 How do you know when to use the right programming language?     -  
 i want some help in java programming     -  
 Java Programming help please?     -  
 Different Styles of Programming     -