From: lucia@savvy.zko.dec.com (Tim Lucia)
Subject: Re: Mysterious DEC OSF C++ compiler warning
Date: 1995/12/20 [thread overview]
Message-ID: <4b99kg$ktg@zk2nws.zko.dec.com> (raw)
In-Reply-To: 4b4rog$m80@holly.cc.uleth.ca
#include <iostream.h>
class junk
{ double a;
public:
junk(void) {};
junk(double x) { a = x;};
junk & operator = (junk & x) { a = x.a; return(*this);};
};
main()
{
junk x;
x = junk(2);
}
// ARM, 12.8 (pp. 295-296)
//
// If all bases and members of a class X have copy constructors accepting
// const arguments, the generated copy constructor for X will take a
// single argument of type const X&, as follows (double has the const ones)
//
// X::X(const X&)
//
// Otherwise it will take a single arugment of type X&:
//
// X::X(X&)
//
// Similarly, for assignment operators:
//
// If all bases...
//
// X& X::operator=(const X&)
//
// or
//
// X& X::operator=(X&) // which is what you have
//
// Since you declared a non-const assignment operator, then the constructor
// junk(2) does not match any declared constructor (default X& X::operator=(const X&))
// so you get the warning on conversion to using the non-const one.
//
// use this: junk & operator = (const junk & x) { a = x.a; return(*this);};
Regards,
Tim
--
Timothy J. Lucia Email: mailto:lucia@zko.dec.com
Digital Equipment Corporation Phone: 603.881.2615
110 Spitbrook Road ZKO2-3/K06 Fax: 603.881.0120
Nashua, NH USA 03062-2698 I'd rather be cycling.
prev parent reply other threads:[~1995-12-20 5:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1995-12-18 5:00 Mysterious DEC OSF C++ compiler warning Marc Roussel
1995-12-18 5:00 ` Morgan Deters
1995-12-19 5:00 ` Andrew Koenig
1995-12-20 5:00 ` Tim Lucia [this message]
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox