Initialising a constant object

F

Fraser Ross

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

Maxim Yegorushkin

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

Fraser Ross

Am I right in thinking that a constant object of a class must have an
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top