Problem with "delete" and what about "friend" classes & functions?

John Kiro johnkirollos at yahoo.com
Fri Jan 5 15:39:35 PST 2007


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;

Another point, I guess D doesn't support "friend" classes or
functions.. wouldn't they be useful sometimes?

Thanks
John


More information about the Digitalmars-d-learn mailing list