I found a piece of code that uses the following statement:
using var_name = data_type;
This is the first time that I encountered it. What does it mean or do?
I found a piece of code that uses the following statement:
using var_name = data_type;
This is the first time that I encountered it. What does it mean or do?
This is a type alias. Quite simply it is a way of identifying an existing data type with a new name. More like giving a synonym since it does not create a new data type.
using diameter = int;
diameter circle = 10;
using is used in C++. typedef which is a keyword in C can be used to do the same thing.
typedef unsigned int size;
typedef int* IntPtr ;
IntPtr x, y, z;
This could be used as an alternative to long/ complicated names of data types. And also in the 1st example if you later on want to change the diameter to float, you would just have to change the definition rather than all the places in the program.