Problem with "delete" and what about "friend" classes & functions?
Kirk McDonald
kirklin.mcdonald at gmail.com
Fri Jan 5 15:56:39 PST 2007
John Kiro wrote:
> Hello
>
> I have a problem with this statement:
>
> delete pDoc.getFile();
>
> It generates this error:
>
> "Error: ((cast(CDoc)(pDoc)).getFile)() is not an lvalue"
>
> The getFile() is a member of CDoc (pDoc is an object of a CDoc
> derived class), and is defined like this:
>
> CFile getFile()
> {
> return m_pFile;
> }
>
> So any idea about the reason of this error?
> The code compiles successfully if I replace the delete statement with:
>
> CFile tmpFile=pDoc.getFile();
> delete tmpFile;
>
'delete' also sets the reference to null. Therefore, it must operate on
an lvalue.
> Another point, I guess D doesn't support "friend" classes or
> functions.. wouldn't they be useful sometimes?
>
Everything in the same module is a 'friend'.
--
Kirk McDonald
Pyd: Wrapping Python with D
http://pyd.dsource.org
More information about the Digitalmars-d-learn
mailing list