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 PostSorry, I can't parse what you're trying to say.
Jump to Postunderneath, passing by reference involves passing the pointer to the thing being referenced; maybe this will give some insights into how it works
so in the example from above,
void foo( int val ) { val = 1; } void foo2( int &ref ) { ref …
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.