Sunday

Solutions to C++ error: expected unqualified-id before 'delete' and C++ error: expected primary-expression before ')' token

What are the two errors of the following program?

#include <iostream>
using namespace std;

void delete()
{
    cout << "You cannot have the word \"delete\" "
         << "as the function name or variable name, "
         << "choose other name instead" << endl;
}

int main(int argc, char* argv[])
{
    delete();

    return 0;
}

Solutions:
take note that the keyword "delete" cannot be used as the function name or variable name

Error 1: expected unqualified-id before 'delete'
Solution:
function name error at the function header
you cannot have the word "delete" as the function name, variable name
use different function name such as deleteNode

Error 2: expected primary-expression before ')' token
Solution:
function caller name error in the main function body
you cannot have the word "delete" as the function caller name, function name, variable name
use different function name such as deleteNode

No comments:

If a hater attacked your age and not the goodness of you

Whether young or old, I've always been known what endures. I've known the very idea of people that were all created equal and deserv...