Shadow Blade
Morrowland Presents Apron Tutorials
game - design - multimedia - web - programming - tutorials - There are currently viewers visiting Apron Tutorials.
   
 
TECHNICAL
GRAPHICAL
SOUND
GAME
WEB
ARTICLE
TOOL
PROJECT
 
 NEWS

  news

  history


 TECHNICAL TUTORIALS

  opengl

  direct3d

  c/c++

  visual basic

  java

  c#


 WEB TUTORIALS

  html

  dhtml

  asp

  php


 IMAGE EDITING

  photoshop

  draw sketch


 3D MODELING

  3d studio


 PROJECTS

  shadow blade

  game environment

  virtual 3d guide

  billy blue flame


 DEMOS

  win32 api


 ARTICLES

  general

  opengl


 COMMUNITY

  about us

  credit

  contact












#include <stdio.h>
#include <iostream>	
using namespace std;					


void swap_numbers_using_pointers(int *num1, int *num2);

void swap_numbers_using_references(int &num1, int &num2);


int main()
{	

	int num1 = 1;
	int num2 = 2;


	// swap the numbers using pointers
	swap_numbers_using_pointers(&num1, &num2);

	// display numbers
	cout << "num1 = " << num1 << endl << "num2 = " << num2;


	cout << endl << endl;


	// swap the numbers using references
	swap_numbers_using_references(num1, num2);
	
	// display numbers
	cout << "num1 = " << num1 << endl << "num2 = " << num2;


	getchar(); // wait for a key to be pressed

	return 0; // return zero
}


void swap_numbers_using_pointers(int *num1, int *num2)
{
	int temp = *num1;
	*num1 = *num2;
	*num2 = temp;
}


void swap_numbers_using_references(int &num1, int &num2)
{ 
	int temp = num1;
	num1 = num2;
	num2 = temp;
}


/*

This tutorial compares the use of pointers and references.
The pointer and reference functions are taken from the two previous tutorials.
I published this extra tutorial just to let you see them together.

*/



Download The Source Code! Download Visual C++ Source Code


I hope you found this c++ tutorial useful!

Don't forget to mention Apron Tutorials in your References!

Best Regards
Ronny André Reierstad

 LINKS

  morrowland home



 GAME DEVELOPEMENT

  nvidia

  gamedev

  polycount


 PROJECTS

  shadow blade

  game environment

  virtual 3d guide

  billy blue flame


 MATH AND PHYSICS

  mathworld

  physicsworld







PLEASE LINK TO


  All rights reserved Morrowland © 2011  
Ronny André Reierstad