OP 16 July, 2018 - 03:05 PM
Hello everbody, I first want to say that I couldn't find the corresponding section of the forum to post and ask things about programming, so I hope here will be okay and I think that this forum should have section for this purpose.
So, I really don't get mean of inline function in C++ , .. Here is one of the codes for this:
I do not understand the purpose of using the inline function, even if some function is not declared inline function, the compiler will perform the same as the code where the inline function is, respectively, both will do the same.
And after this question, I have question about recursion, I get it how storage works and purpose of recursion, but if anyone have some code and explanation of that code is not too complicated I would like to write to me here or in messages.
Thanks :)
So, I really don't get mean of inline function in C++ , .. Here is one of the codes for this:
Code:
1: // Listing 5.9 - demonstrates inline functions
2:
3: #include <iostream.h>
4:
5: inline int Double(int);
6:
7: int main()
8: {
9: int target;
10:
11: cout << "Enter a number to work with: ";
12: cin >> target;
13: cout << "\n";
14:
15: target = Double(target);
16: cout << "Target: " << target << endl;
17:
18: target = Double(target);
19: cout << "Target: " << target << endl;
20:
21:
22: target = Double(target);
23: cout << "Target: " << target << endl;
24: return 0;
25: }
26:
27: int Double(int target)
28: {
29: return 2*target;
30: }
I do not understand the purpose of using the inline function, even if some function is not declared inline function, the compiler will perform the same as the code where the inline function is, respectively, both will do the same.
And after this question, I have question about recursion, I get it how storage works and purpose of recursion, but if anyone have some code and explanation of that code is not too complicated I would like to write to me here or in messages.
Thanks :)
P S H Y O T I C
☻♥
☻♥
![[Image: Czwhvkg.png]](https://i.imgur.com/Czwhvkg.png)