Call by Value vs Call by Reference in C++ - Difference with Examples
In C++, arguments can be passed to a function in different ways. Two commonly used methods are Call by Value and Call by Reference . The main difference is how a function receives and works with the data supplied by the calling function. C++ में किसी Function को Arguments अलग-अलग तरीकों से Pass किए जा सकते हैं। इनमें दो प्रमुख तरीके हैं Call by Value और Call by Reference । इन दोनों में मुख्य अंतर यह है कि Function को Calling Function से Data किस प्रकार प्राप्त होता है और उसके साथ कार्य करता है। 1. Call by Value – कॉल बाय वैल्यू In Call by Value, a copy of the actual argument is passed to the function. The function works with its own copy, so changes made to the formal parameters do not affect the original variables. Call by Value में Actual Argument की एक Copy Function को Pass की जाती है। Function अपनी Copy पर कार्य करता है, इसलिए Formal Parameters में किए गए बदलाव Original Variables को प्रभावित नहीं करते हैं। Syntax: return_type function_name(data_type parameter) { // Statements...