Eight
Eight

Reputation: 4284

what is int(a)(1)? is this a valid c++ syntax?

#include <iostream>
int main()
{
    // ------- some statements ---------

    int(a)(1);

    // -------- some other statements .......
    return 0;
}

I saw this statement in a C++ program. This did not result in a syntax error.

What is a here? Is this valid C++ syntax?

Upvotes: 19

Views: 4050

Answers (1)

GManNickG
GManNickG

Reputation: 504103

It is okay to put the name of the variable in parenthesis:

int i;
int (i); // exact same

So in your case:

int a(1); // initialized with 1
int (a)(1); // exact same

Upvotes: 29

Related Questions