What is the difference? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the difference?

what is the difference between this two options: int a = get_rand_number()//it returns number and int a = get_rand_number//also returns number Thanks for your help😄

28th Oct 2018, 12:50 PM
Oleg Storm
Oleg Storm - avatar
2 Answers
+ 3
If get_rand_number is declared a sa function, get_rand_number would return a function pointer. get_rand_number() would be a function call. E.g. void function() { std::cout << "Function"; } int main() { void (*fptr)() = function; fptr(); return 0; }
28th Oct 2018, 2:05 PM
Hatsy Rei
Hatsy Rei - avatar
0
I think there is a difference especially when using reference functions🤔
28th Oct 2018, 12:52 PM
Oleg Storm
Oleg Storm - avatar