hello , I want to know what is the difference between passing by value and reference , and if you can put an example with simple out put .
bis student
0
Newbie Poster
Recommended Answers
Jump to PostPassing by value is better described as pass by copy. A copy of the value is made and sent to a function. This means that if you change the value in the function, the original remains the same:
#include <iostream> void foo ( int copy ) { …
Jump to Postvoid foo( int val ) { val = 1; }
void foo2( int &ref ) { ref = 1; }
First is by value, second is by reference. You can change the value of 'ref' in foo2 by setting its value and the value …
Jump to PostSorry, I can't parse what you're trying to say.
All 10 Replies
Narue
5,707
Bad Cop
Team Colleague
twomers
408
Posting Virtuoso
bis student
0
Newbie Poster
bis student
0
Newbie Poster
Narue
5,707
Bad Cop
Team Colleague
Duoas
1,025
Postaholic
Featured Poster
rajatC
-1
Junior Poster
bugmenot
25
Posting Whiz in Training
imabutha
0
Newbie Poster
twomers
408
Posting Virtuoso
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.