Search code examples
c++visual-studio-2015logical-operatorsdelete-operator

C++ , '&&': illegal, right operand has type 'void'


I downloaded an old project (2008) from codeproject, and now I'm trying to compile it and as a result I'm getting such errors:

'&&': illegal, right operand has type 'void'

in here:

    while( hItem_i )
    {
        PINodeData pNodeData = GetItemData( hItem_i );
        pNodeData && pNodeData->DeleteNodeData() && delete pNodeData; //HERE!!!
....
     }

what's wrong?


Solution

  • While if is definitely better, you can use &&:

    pNodeData && pNodeData->DeleteNodeData() && (delete pNodeData, 1);