🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Dan DuVarney Tue, 01 Nov 1988 03:44
possible g++ bug
#1517
Author: Dan DuVarney
Date: Tue, 01 Nov 1988 03:44
34 lines
1246 bytes
I am using g++ version 1.25 on a Sun 3/50 running SunOS 3.5.
It appears that g++ is incorrectly choosing which constructor
to use in certain cases. For example:

--------------------------------------------------
#include "stream.h"

class F {
  int i;
  float f;
public:
  F(int i1, float f1);
  F(int i1, int i2);
}

F::F(int i1, float f1)
 { i = i1; f = f1; cout << "int, float constructor called\n"; }

F::F(int i1, int i2)
 { i = i1 + i2; f = 0.0; cout << "int, int constructor called\n"; }

main()
{
  F f(0,0.0);
}
----------------------------------------------------

When I run this program the output is "int, int constructor called."
It seems to me that the int, float constructor should be called
instead -- although I am a C++ novice and could be wrong.


-- 
Dan DuVarney      ...!mcnc!rti!dg-rtp!duvarney
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