Wednesday, 14 October 2015

What is compile time & What is run time ? ?

We write program in high level language. But computer can understand only binary language (0's and 1's). In order to achieve this conversion from High level language to Machine language,compiler is used. The time taken by the compiler to convert the High level language to machine language(binary language) is called as compile time.

The time taken to execute the compiled program is called run time or execution time.


Tuesday, 13 October 2015

What is inline function in C++ ? ?

Sometimes we may come across using a small function many times in a program. Consider we use normal function definition. Whenever a normal function call is encountered, the program will store the memory address of the instructions which are immediately following the function call. It load the function being called and executes this function and stores the return value if any. Now it jumps back to the stored memory address,which is the memory address of the instruction which is immediate to the function call. So too much run time is involved here. In such cases we can declare the function as inline. This declaration is done by just keeping "inline" before the actual function definition. If we use this inline declaration, then compiler replaces all the function call statements with the function definition so that jumping can be avoided,which in turn decreases the run-time for the program.

***By using inline function, we are increasing the compile time  and decreasing the run time.

***It is just a suggestion to the compiler but not a compulsion. i.e, If the function is big,but it is declared as inline, the compiler won't treat it as inline function, it just treats as a normal function only.