This is understood as *x is of type int and so x is a pointer.
So, how would you explain it in the same way for this pointer declaration below:
char (* ptr)[3]
I know the way to read it as "ptr is pointer to such one dimensional array of size three which content char type data" but I just wonder about how would you explain it as the way of int *x.
Thanks! This is interesting way to look at it.
How about this one?
float (* ptr)(int)
Let's me try that:
ptr is of type float (*) (int). Deference ptr by doing *ptr and you get the type float (int).
So ptr is a pointer to a function whose parameter is int type and return a float.
#include <iostream>
#include <type_traits>
int main()
{
using function_type = int() ; // nullary function returning int
typedefint function_type() ; // same as above
using ptr_function_type = function_type* ; // pointer to function_type
typedef function_type* ptr_function_type ; // same as above
using array_type = ptr_function_type[5] ; // array of 5 ptr_function_type
typedef ptr_function_type array_type[5] ; // same as above
using ptr_array_type = array_type* ; // pointer to array_type
typedef array_type* ptr_array_type ; // same as above
static_assert( std::is_same< int( * (*)[5] )(), ptr_array_type >::value, "must be the same type" ) ;
int ( * ( * ptr ) [ 5 ] ) ( ) = nullptr ;
ptr_array_type ptr2 = ptr ;
static_assert( std::is_same< decltype(ptr), decltype(ptr2) >::value, "must be of the same type" ) ;
}