All pastes #284230 Raw Edit

Unnamed

public text v1 · immutable
#284230 ·published 2006-12-18 23:19 UTC
rendered paste body
// test.cpp

#include <iostream>
using namespace std;

void swapValue(int n1, int n2);
void swapValue(int n1, int n2)
{
	int temp;
	temp = n1;
	n1 = n2;
	n2 = temp;

	cout << n1 << " - n1" << endl;
	cout << n2 << " - n2" << endl;
}

void swapReference(int& m1, int& m2);
void swapReference(int& m1, int& m2)
{
	int temp;
	temp = m1;
	m1 = m2;
	m2 = temp;

	cout << m1 << " - n1" << endl;
	cout << m2 << " - n2" << endl;
}

int main()
{
	swapValue(5, 10);
	cout << endl;
	swapReference(20, 40);
	return 0;	
}

#I get errorg++ test.cpp 
test.cpp: In function ‘int main()’:
test.cpp:34: error: invalid initialization of non-const reference of type ‘int&’ from a temporary of type ‘int’
test.cpp:19: error: in passing argument 1 of ‘void swapReference(int&, int&)’