🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Lassi A. Tuura Tue, 16 Jan 1996 10:17
can initialization be used with new[]?
#3014
Author: Lassi A. Tuura
Date: Tue, 16 Jan 1996 10:17
40 lines
1922 bytes
One compiler I need to use has problems with the following code:
---------------
#include <new.h>
class T {
public:
    T (int n) : _n (n) { }
    T (const T &ref) : _n (ref._n) { }
    ~T () { }

private:
    int _n;
};

void f ()
{
     T *ptr = new T [10] (1);  // line 14
}
---------------

In particular, it complains about the initializer to the vector new:
  CC: "test.cc", line 14: error: initializer for array of class object
			  created using `new' (1248)

Another compiler has no problems with the code, and the one giving the
error message has not proved to be reliable.  The question is: Is this
legal C++?  I read thru 5.3.4 from the april draft and as far as I
understood the code was flagged ill-formed.  Did I interpret the draft
correctly?  If I did, how am I supposed to allocate an array of
objects of class T?  With explicit calls to operator new and placement
new?

BTW, is either comp.lang.c++.moderated or comp.std.c++ archived
somewhere?  I recall I have read something about this matter some time
back.

//LaT
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Re: can initialization be used with new[]?
#3018
Author: Fergus Henderson
Date: Tue, 16 Jan 1996 18:29
22 lines
1531 bytes
"Lassi A. Tuura" <Lassi.Tuura@hut.fi> writes:

>BTW, is either comp.lang.c++.moderated or comp.std.c++ archived
>somewhere?  I recall I have read something about this matter some time
>back.

As far as I know, comp.std.c++ is not archived anywhere.
(Any volunteers for this task...?)

I do have a record of all of the articles that I have
approved for comp.std.c++ (i.e. roughly 1/3 of the articles
since Aug 95); it is 338k gzipped, and since I happened to
have it lying around, I've made it available for downloading
at <http://www.cs.mu.oz.au/~fjh/comp.std.c++/posted.log.gz>.

--
Fergus Henderson             	WWW: http://www.cs.mu.oz.au/~fjh
fjh@cs.mu.oz.au              	PGP: finger fjh@128.250.37.3
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
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