Monday, 8 July 2013

what is advantage of c++ over structures language | what is advantage of c++

we know memory is always at the premium . In block structured  programming we can save memory by controlling the life of variables.
          for example , consider the following function
                        
           void fun()
           {
                    // 120 statements
                   {
                       
                            int a;
                     
                           //statement using a;
                         
                   }
             
                    // 100 more statements;
          }

here a has been defined inside a bloack as it is not needed once the control passes the blocl . As soon as the control outside the block a dies thereby freeing the memory occupied by it.had a been defined at the beginning of the function.  a would have survived till execution of the function had not come to an end;
      

0 comments:

Post a Comment