[comp.lang.c++] Vector classes in 1.2

ericg@ucschu.ucsc.edu (Eric Goodman) (07/17/90)

In article <6570@helios.TAMU.EDU> jeffw@cs.tamu.edu (Jeffrey A Waller) 
writes:
> I think I remember in the 1.2 Stroustrup book that to be an element of a 
> vector, a class must have a constructor with no arguments.  
> IntArray(int sz = ArraySize) should qualify, but apparently TC++ dosen't
> recognize it, for a quick fix--maybe not much help, redefine
> IntArray(int sz = ArraySize) as two constructors.  IntArray(int sz) and
> IntArray(), in which sz is set to ArraySize, maybe that will work.

To be a vector type in 1.2 (and maybe later) versions, a class must have a 
constructor that takes no arguments *even if* they are defaulted so that 
none need be passed.  Because the compiler implicitly passes them you're 
still confusing it.

IntArray(int sz = ArraySize) 

is not a legal constructor for a vector type, its not just a TC++ bug (if 
it's pre 2.0).

Eric Goodman, UC Santa Cruz

ericg@ucschu.ucsc.edu                              ericg@ucschu.bitnet
Eric_Goodman.staff@macmail.ucsc.edu            ...!ucbvax!ucscc!ucschu!ericg

shap@thebeach.wpd.sgi.com (Jonathan Shapiro) (07/17/90)

In article <5184@darkstar.ucsc.edu>, ericg@ucschu.ucsc.edu (Eric
Goodman) writes:

> To be a vector type in 1.2 (and maybe later) versions, a class must have a 
> constructor that takes no arguments *even if* they are defaulted so that 
> none need be passed.  Because the compiler implicitly passes them you're 
> still confusing it.
> 
> IntArray(int sz = ArraySize) 
> 
> is not a legal constructor for a vector type, its not just a TC++ bug (if 
> it's pre 2.0).
> 
> Eric Goodman, UC Santa Cruz

This was relaxed in 2.1, which is moot from the standpoint of what works
right now, but may be of interest to some.  Take a look at the maroon book.

Jon