Apersand & or asterisk * | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Apersand & or asterisk *

Which special sign to use in declaration (definition) of function to pass by reference? & or *? Because I've seen func(int &a) {} instead of func(int *a). Some help and explain? :-) Regards.

2nd Nov 2017, 6:37 AM
Marcin Papiernik
Marcin Papiernik - avatar
2 Answers
+ 6
Both can be used in a sense as pointers are reference BUT your answer is what follow : * means that the variable is a pointer & means that the variable is a reference
2nd Nov 2017, 6:58 AM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 2
Thanks, guys. I need to think it over. ;-)
3rd Nov 2017, 5:17 AM
Marcin Papiernik
Marcin Papiernik - avatar