Inline functions effectively remove the function call altogether. However, just because a function is declared inline is no guarantee it will be inline expanded. it is merely a hint to the compiler that the function should considered for inline expansion, nothing more.
To understand how inline expansion helps, consider the following code:
void print(int x) {
std::cout << x << std::endl; }
int main()
{
int x=5;
print(x);
x*=3;
print(x);
print(++x);
return(0);
}
If the print() function could be inline expanded, it would be the same as if you'd written the following:
int main()
{
int x=5;
std::cout << x << std::endl;
x*=3;
std::cout << x << std::endl;
std::cout << ++x << std::endl;
return(0);
}
Our code may be a little larger, but it will execute that much faster because we've completely eliminated all three function calls. But while we could expand functions inline manually, as shown above, it makes no sense to do so. In a larger program where the function might be called several dozen times, it becomes that much harder to manage the inline code because there are so many instances of it. By keeping the function and declaring it inline, we can easily modify the function's behaviour because the code is all in one place. More fundamentally, however, if we manually expand functions inline, our code becomes that much larger, and performance is directly related to code size.
By giving the compiler hints as to which functions should be inline expanded, we allow the compiler to decide which is better in each case. The compiler uses complex algorithms to determine the best compromise between code size and performance. A function that is called many times but has little actual code is an ideal candidate for inline expansion, but then so is any function, regardless of complexity, that is called just the once. In the latter case the function may not be absolutely necessary, but functions can help make the code that uses them that little bit more readable and easier to understand, with much less need for commentary.
Even recursive functions can be inline expanded, but usually there is a limit to the depth of recursion (16 being a common limit). This can greatly increase the performance of the function at the expense of code size, which may affect other areas of the program. However, it is not something that should concern the programmer. The compiler is a better judge of what should be expanded and what should not. Even so, some compilers also include a non-standard force_inline flag that can override the compiler's decision, but this is best used sparingly, and only when the programmer is absolutely sure the performance gained will not cause problems elsewhere due to the increased code size.
...a function call.
Every C plus plus program that is a main program must have the function 'main'.
to locate coordinates ..
Use the C++ getline() function from the standard library.
There is no such thing. You probably meant the main function. The main function is the only function that is required as it serves as the entry point of the program.
There is no such term as "building function" in C++.
theriyadhu
Y = 2X + 8 is a linear function of the form, Y = mX + c. A line.
...a function call.
yes,we can make function inline
Every C plus plus program that is a main program must have the function 'main'.
Control is returning to the caller of the function.
method
It is the first function that gets called when the program is executed.
Yes. It is the function f(x) = c where c is a constant.
It is a quadratic function which represents a parabola.
The main function is the entry point of your application. Its primary purpose is to process command-line switches (if any) and to invoke the appropriate functions. For trivial applications the main function may be the only function, however separating blocks of code into re-usable functions make code much easier to read.