//值传递:替代形参的只是实参的值
//引用传递:传递的是变量(而不是变量的值)
// (函数调用中的相应实参必须是变量)
// input.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std ;
void getInput(int num1, int num2) ;
void showResults(int num1, int num2) ;
int main(int argc, char* argv[])
{
int firstNumber = 0, secondNumber = 0;
getInput(firstNumber, secondNumber);
showResults(firstNumber, secondNumber);
return 0;
}
void getInput(int num1, int num2){
cout <<"Enter two integers: ";
cin >>num1;
cin >>num2;
}
void showResults(int num1, int num2){
cout <<"In received order the numbers are: "
<< num1 <<'\t' << num2 <<endl;
}

// input.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std ;
void getInput(int &num1, int &num2) ;
void showResults(int num1, int num2) ;
int main(int argc, char* argv[])
{
int firstNumber = 0, secondNumber = 0;
getInput(firstNumber, secondNumber);
showResults(firstNumber, secondNumber);
return 0;
}
void getInput(int &num1, int &num2){
cout <<"Enter two integers: ";
cin >>num1;
cin >>num2;
}
void showResults(int num1, int num2){
cout <<"In received order the numbers are: "
<< num1 <<'\t' << num2 <<endl;
}

posted on
浙公网安备 33010602011771号