Topic: Proposal: Constructor for {} initialisation
Author: Ioannis Vranos <ivr@guesswh.at.grad.com>
Date: Tue, 7 Sep 2004 22:14:37 GMT Raw View
Proposal for a way to define constructors for {} type initialisation.
The constructor defining such an initialisation includes brackets inside
the parenthesis:
SomeType( { const T * const input, const size_t SIZE } );
input is the initialisation sequence and SIZE is the length of the
initialisation sequence.
An example with a definition:
class SomeType
{
// ...
public:
// ...
SomeType( { const int * const input, const size_t SIZE } )
{
for(size_t i=0; i<SIZE; ++i)
{
// assignments from input
}
}
// ...
};
int main()
{
SomeType obj = {1,2,3,4};
// ...
SomeType *p=new SomeType( {1,2,3,4,5} );
// ...
delete p;
// ...
}
Regards,
Ioannis Vranos
http://www23.brinkster.com/noicys
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]