#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 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.
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.
The int keyword is used to indicate integers. Its size is usually 4 bytes. Meaning, it can store values from -2147483648 to 2147483647.
&n writes the address of n . The address of a variable points to the value of that variable.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With