Passing Arguments by Value and by Reference in C++

#include <iostream>
using namespace std;
void func(int x)
{
    cout << "Argument passed by value : " << x << endl;
}

void func2(int &byref)
{
    byref++;
    cout << "Argument passed by refrence: " << byref;
}

int main()
{
    func(5);
    int x = 300;
    func2(x);
}

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *