What's the difference between these two function declarations in C/C++? | Sololearn: Learn to code for FREE!

0

What's the difference between these two function declarations in C/C++?

return_type function(arg_type * arg); return_type function(arg_type &arg); What's the difference between these two declarations?

4/8/2021 7:00:55 AM

Antônio Gabriel Zeni Landim

4 Answers

New Answer

+3

The first function accepts a pointer as an argument while the second makes a direct reference to it's argument

+2

Note that it's not 'C/C++'. The second declaration is NOT valid in C, it is only valid in C++.

+2

Also, you have 3 questions with the same content. Please delete the other 2 as they are duplicates https://sololearn.com/discuss/2749239/?ref=app https://sololearn.com/discuss/2749237/?ref=app

0

Sorry for the duplicates. SL was acting all weird.