V
Victor Bazarov
Hello,
Take a look at this program:
-----------------------------------
class B
{
B(const B&);
B& operator=(const B&);
public:
B(int);
};
class C : public B
{
public:
C(int);
};
int main()
{
C c = C(42); // Comeau: no error
B b = B(42); // Comeau: error
}
-----------------------------------
Both 'c' and 'b' are copy-constructed, as I understand it.
B's copy c-tor is inaccessible, so construction of 'b' is
ill-formed. And Comeau (online test drive) flags it such.
But it lets the construction of 'c' through. Should it?
As I understand it, a temporary can be omitted, but its
creation should be possible (12.2/1) as if it weren't omitted.
And since C's copy c-tor cannot be created (12.8/7), the code
that requires (or would require) it is also ill-formed.
Where do I err? Or do I?
Thanks!
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Take a look at this program:
-----------------------------------
class B
{
B(const B&);
B& operator=(const B&);
public:
B(int);
};
class C : public B
{
public:
C(int);
};
int main()
{
C c = C(42); // Comeau: no error
B b = B(42); // Comeau: error
}
-----------------------------------
Both 'c' and 'b' are copy-constructed, as I understand it.
B's copy c-tor is inaccessible, so construction of 'b' is
ill-formed. And Comeau (online test drive) flags it such.
But it lets the construction of 'c' through. Should it?
As I understand it, a temporary can be omitted, but its
creation should be possible (12.2/1) as if it weren't omitted.
And since C's copy c-tor cannot be created (12.8/7), the code
that requires (or would require) it is also ill-formed.
Where do I err? Or do I?
Thanks!
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]