+ 2
What is the difference between call by pointer and call by reference in C++?
Suppose two functions is initialize like, int swap (int *a, int *b); int swap2(int &a, int &b); what is the difference between them. is in C call by call by reference and call by pointer are same? why in C++ they are different.
1 ответ
+ 3
Accepting the references, you tell to client code that it must pass you valid objects. In case of pointers client code can pass nullptr or any other broken pointer. Also the difference in syntax inside swap functions.