c++ default operators

Joe Buck Joe.Buck@synopsys.COM
Fri Sep 23 22:44:00 GMT 2005


On Fri, Sep 23, 2005 at 07:09:21PM +0200, Tommy Vercetti wrote:
> I was told that gcc by default, for every class creates operator =, and
> probably something else. This makes binary file bit larger than it
> suppose to be. Is it true, and if so, why this is the case ? Can gcc
> simply not generate that operator?

In the C++ language, we have the concept of the default assignment
operator and the default copy constructor, which are created if needed
by the compiler.  But gcc won't create these if they aren't used.

Another extra function people sometimes complain about is the two copies
of the constructor: the in-charge version is for constructing an instance
of the class, and the not-in-charge version is for initializing the base
portion of a derived class.  Getting rid of the not-in-charge version,
for cases where it isn't needed, would require something like Java's
"final" keyword.







More information about the Gcc mailing list