[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c++

Initialising a constant object

Fraser Ross

11/28/2008 4:25:00 PM

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.


2 Answers

Maxim Yegorushkin

11/28/2008 5:15:00 PM

0

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

11/29/2008 4:28:00 PM

0

>> 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.