|
Boost : |
From: Markus Schöpflin (markus.schoepflin_at_[hidden])
Date: 2002-10-01 03:44:32
Gennadiy Rozental wrote:
>
[snip]
> Continue my question: does the following should compile?
>
> class A {
> public:
> A() {};
> int field;
> private:
> A( A const& );
> void operator=( A const& );
> };
>
> void foo( A const& a )
> {
> int i = a.field;
> }
>
> void moo()
> {
> foo( A() );
> }
>
No, because you're trying to bind a rvalue (the temporary object
created with A()) to a const reference. And for this to work,
the class A must have a visible copy constructor.
Markus
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk