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:

Interactive Proof System

Interactive proof systems were formulated in 1985 as published in the seminal research paper titled "The Knowledge Complexity of Intera...