Why can't return an object instance by ref?
Jarrett Billingsley
jarrett.billingsley at gmail.com
Thu Jul 16 19:37:37 PDT 2009
On Thu, Jul 16, 2009 at 9:47 PM, Sam Hu<samhudotsamhu at gmail.com> wrote:
> Hi,
>
> With below code:
> class A
> {
> }
> class B
> {
> public:
> ref A createA() // q2:without type name A is also OK?
> {
> return new A;//q1
> }
>
> }
> My questions are:
> q1.why this can't work?
Because 'new A' is not an lvalue. Why do you want to return a
reference to a class, anyway? Classes already *are* by reference.
More information about the Digitalmars-d-learn
mailing list