Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

#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?

like image 692
Eight Avatar asked Aug 01 '12 01:08

Eight


People also ask

Is int valid in C?

Like integers, -321, 497, 19345, and -976812 are all valid, but now 4.5, 0.0004, -324.984, and other non-whole numbers are valid too. C allows us to choose between several different options with our data types because they are all stored in different ways on the computer.

What does int * A mean in C?

A is some address of pointer variable. Int*a means we are dereferencing a to get the address of actual variable that is stored in pointer variable. And by *(int*a) means we are dereferencing above address to get actual value.

What does int () do in C++?

The int keyword is used to indicate integers. Its size is usually 4 bytes. Meaning, it can store values from -2147483648 to 2147483647.

WHAT IS &N in C?

&n writes the address of n . The address of a variable points to the value of that variable.


1 Answers

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
like image 185
GManNickG Avatar answered Oct 01 '22 13:10

GManNickG