tpdanax.blogg.se

Basic programming language pdf
Basic programming language pdf










Note that naming a type after its representation rather than its purpose is not necessarily a good idea (§6.3.3).The using keyword can also be used to introduce a template alias (§23.6). The int16_t, int32_t, and other such aliasescan be found in (§43.7).

#Basic programming language pdf code

Having written our code interms of int32_t, rather than ‘‘plain int,’’ we can port our code to a machine with sizeof(int)=2 byredefining the single occurrence of int32_t in our code to use a longer integer:using int32_t = long The _t suffix is conventional for aliases (‘‘typedefs’’). Thename int32_t indicates that we want it to represent a 32-bit integer. For example:typedef int int32_t typedef short int16_t typedef void(∗PtoF)(int) // equivalent to ‘‘using int32_t = int ’’// equivalent to ‘‘using int16_t = short ’’// equivalent to ‘‘using PtoF = void(*)(int) ’’Aliases are used when we want to insulate our code from details of the underlying machine. For example:Pchar p1 = nullptr char∗ p3 = p1 // p1 is a char*// finePeople who would like to have distinct types with identical semantics or identical representationshould look at enumerations (§8.4) and classes (Chapter 16).An older syntax using the keyword typedef and placing the name being declared where it wouldhave been in a declaration of a variable can equivalently be used in many contexts. That is, analias refers to the type for which it is an alias.










Basic programming language pdf