A simple call by reference demonstration by adding something in the original value itself.
#include #include void addsomething(int &); int something=5; int main() { clrscr(); int a=10; cout<<"Before function call: a = "< Source Code #include using namespace std; void addsomething(int &); int something=5; int main() { int a=10; cout<<"Before function call: a = "< #include using namespace std; void addsomething(int &); int something=5; int main() { int a=10; cout<<"Before function call: a = "< Test it !Test CPP Code !XThe code has been copied automatically for you in the clipboard. After that open any of the service and press cntrl-v to paste in the given code area. Needs a bit of tweaking as per the link. repl.it CPP cpp.sh CPP Ideone CPP Browxy CPP Show Run Output Before function call: a = 10 After function call: a = 15 Suggested Filename(s): callbyref-demo.cpp, cbrdemo.cpp sunmitra| Created: 15-Jan-2018 | Updated: 16-Jan-2018| Post Views: 381
Before function call: a = 10 After function call: a = 15
Suggested Filename(s): callbyref-demo.cpp, cbrdemo.cpp
sunmitra| Created: 15-Jan-2018 | Updated: 16-Jan-2018|
Functions Reference Passing/Returning