Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Initialising a constant object

0 views
Skip to first unread message

Fraser Ross

unread,
Nov 28, 2008, 11:25:16 AM11/28/08
to
Am I right in thinking that a constant object of a class must have an
accessible user provided constructor if it is not list-initialised?

Fraser.


Maxim Yegorushkin

unread,
Nov 28, 2008, 12:15:06 PM11/28/08
to
On Nov 28, 4:25 pm, "Fraser Ross" <z...@zzzzzz.com> wrote:
> Am I right in thinking that a constant object of a class must have an
> accessible user provided constructor if it is not list-initialised?

You are quite right.

--
Max

Fraser Ross

unread,
Nov 29, 2008, 11:28:12 AM11/29/08
to
>> Am I right in thinking that a constant object of a class must have an
>> accessible user provided constructor if it is not list-initialised?

>You are quite right.

class B {
};

class A {
B b_;
public:
A() {}
};

B const b={};
A const a;

void func() {
B const b={};
A const a;
}

Borlands compiler confirms my deductions with the above code.

Fraser.


0 new messages