🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Martin Hitz Wed, 26 Jun 1991 14:05
Overloading Resolution
#1342
Author: Martin Hitz
Date: Wed, 26 Jun 1991 14:05
33 lines
1498 bytes
In the course of testing my understanding of the rules for argument matching
given in section 13.2 in the ARM, I tried to predict the outcome of the
program given below. In order to verify my conclusions, I tried the
program with 4 different compilers (GNU g++, Sun's cfront, Zortech, and
Borland C++). As the results have been somewhat arbitrary, I'd like to
get your comments on who's right:

#include <stream.h>

void f (const double &, double, void *)		{ cout << 1; }
void f (double &, int, const char * = 0)	{ cout << 2; }
void f (int) 					{ cout << 3; }
void f (long, int = 0) 				{ cout << 4; }

main ()
{
	double b;
	const double pi = 3.14;
	
     			//	Z	g++	cfront	BC++
     			//---------------------------------------
	f(1.1, 1, f); 	//	1	err	err	1
	f(1, 1, "Y");	//	err	err	err	2
	f(3, 1.1, 0); 	// 	err	err	1	err
	f(1.1, 3, (void*)0);//	err	1	1	err
	f(1, 1);	// 	err	4	4	4
	f(pi, pi, "Y");	//	1	1	1	err
	f(0L); 		// 	4	3	4	4
	f(0L, 'a');	//	err	4	4	4
	f(pi);		//	err	3	err	err
}

Thanks, Martin Hitz@csi.uottawa.ca
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads