bug search with swap function

Bjarne Stroustrup “Programming Principles and Practice Using C++”
Chapter 8 Drill 2
Using std_lib_facilities.h by Bjarne Stroustrup.

main.cpp main file

//	Philipp Siedler
//	Bjarne Stroustrup's PP
//	Chapter 8 Drill 2

#include "std_lib_facilities.h"

void swap_v(int a, int b) {
	int temp;
	temp = a;
	a = b;
	b = temp;
}

void swap_r(int& a, int& b) {
	int temp;
	temp = a;
	a = b;
	b = temp;
}

/* Nope.
void swap_cr(const int& a,const int& b) {
	int temp;
	temp = a;
	a = b;
	b = temp;
}
*/

int main() {
	//int x = 7;
	//int y = 9;
	//swap_v(x, y); Nope.
	//swap_r(x, y); Success!
	//cout << "x: " << x << " y: " << y << "\n";

	//swap_v(7, 9);
	//cout << "x: " << x << " y: " << y << "\n";
	//swap_r(7, 9); Nope.

	//const int cx = 7;
	//const int cy = 9;
	//swap_v(cx, cy); Nope.
	//swap_r(cx, cy); //Nope.
	//cout << "cx: " << cx << " cy: " << cy << "\n";

	//swap_v(7.7, 9.9); Nope.
	//swap_r(7.7, 9.9); Nope.

	//double dx = 7.7;
	//double dy = 9.9;
	//swap_v(dx, dy); Nope.
	//swap_r(dx, dy); Nope.
	//cout << "dx: " << dx << " dy: " << dy << "\n";

	keep_window_open(".");
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.