Ambiguous KLed constructors

Richard Dale Richard_Dale at tipitina.demon.co.uk
Wed Nov 5 14:01:41 GMT 2003


On Wednesday 05 November 2003 12:38, Guillaume Laurent wrote:
> On Wednesday 05 November 2003 13:31, Richard Dale wrote:
> > KLed::KLed() with no args gives a compiler error as it's ambiguous. What
> > is the correct C++ behaviour - take the first one - or should this really
> > be a compilation error which is being missed by gcc?
>
> The latter, although the error isn't really missed by gcc in that it can't
> spot it until you actually try to use the ctor in an ambiguous way. Anyway,
> the 1st ctor is superfluous and should be removed.
Thanks. But if the constructor below was removed, and you made a call to 'new 
KLed(myparent)' it wouldn't do the initialisation of the color and dark 
factor would it?

KLed::KLed(QWidget *parent, const char *name)
  : QWidget( parent, name),
    led_state(On),
    led_look(Raised),
    led_shape(Circular)
{
  QColor col(green);
  d = new KLed::KLedPrivate;
  d->dark_factor = 300;
  d->offcolor = col.dark(300);

  setColor(col);
}

Is it correct to remove the default value for the parent arg, like this and in 
the attached patch:

  /**
   * Constructs a green, round LED widget which will initially
   * be turned on.
   */
  KLed(QWidget *parent, const char *name=0);

If so, is it ok to apply the patch to kled.h?

-- Richard

-------------- next part --------------
A non-text attachment was scrubbed...
Name: kled_constructor.diff
Type: text/x-diff
Size: 537 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20031105/84078284/attachment.diff>


More information about the kde-core-devel mailing list