Selasa, 04 Oktober 2016

Different ways of passing data to methods in C++

In C++ we have three ways for passing arguments to a function. They are: pass-by-value, pass-by-reference, and pass-by-address.   Pass-by-value Generally used way to pass arguments is pass-by-value. In this method, the arguments passed in the function call are copied to formal parameters in the function definition. So, any changes made to the formal parameters are not reflected on the actual parameters. Consider the following swap function which demonstrates pass-by-value: 1 2 3 4 5 6 void swap(int x, int y) { int temp = x; x = y; y = temp; }   Let’s assume that in the main() function we are writing the

The post Different ways of passing data to methods in C++ appeared first on Coding Security.


Different ways of passing data to methods in C++
read more

Tidak ada komentar:

Posting Komentar