Thread View: comp.std.c++
1 messages
1 total messages
Started by Anders Lindback
Sun, 14 Apr 1996 12:35
Initialization of references.
Author: Anders Lindback
Date: Sun, 14 Apr 1996 12:35
Date: Sun, 14 Apr 1996 12:35
45 lines
1942 bytes
1942 bytes
The september 95 Working draft 8.3.1 says:
"A reference shall be initialized to refer to a valid object or function."
What is a valid object ? I can't find a good decription of that in
the draft. Is it:
1. An object that has storage.
2. An object which constructor has executed.
3. A typo ?
4. An out-of-date sentence in the draft.
5. None of the above ?
Example code from gnu.g++.help:
>#include <iostream.h>
>
>class Foo
>{
>public:
> Foo (int size_arg = 0) : size (my_size), my_size (size_arg),
> values (new double [size]) {}>
~Foo () { delete values; }
> int const& size;
>private:
> int my_size;
> double* values;
>};
Is this code correct C++ code or not ?
Or must one change the order of the member variables in the
class so that my_size is before size and get to be intialized
first ?
And what will happend if they not are integers but actuall classes
with constructors ?
Anders
---
[ 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 ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
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