Monday, August 31, 2009

Qualifiers: long, long long, short, unsigned, and signed

 

Pages from Programming in Objective-C 2.0 (2nd Edition)datatype_Page_1.png Pages from Programming in Objective-C 2.0 (2nd Edition)datatype_Page_2.png

 

long int numberOfPoints = 131071100L;

A constant value of type long int is formed by optionally appending the letter L (in upper or lower case) onto the end of an integer constant.

long long int maxAllowedStorage;  OR “%lli”.

 

long double US_deficit_2004=1.234e+7L; OR “%le” “%lf ” OR “%lg”

SHORT INT

In any case, you are guaranteed that the amount of space allocated for a short int will not be less than 16 bits

No way exists to explicitly write a constant of type short int in Objective-C.

unsigned int

unsigned int counter =0x00ffU or

unsigned long int counter=20000UL;

When declaring variables to be of type long int, short int, or unsigned int, you can omit the keyword int.

The signed qualifier can be used to explicitly tell the compiler that a particular variable
is a signed quantity. Its use is primarily in front of the char declaration

Type id

The id data type is used to store an object of any type. In a sense, it is a generic object type. For example, this line declares number to be a variable of type id:

id number;

 

So, the following declares a class method that returns a value
of type id:
 

+allocInit;

The id type is the basis for very important features in Objective-C know as polymorphism and dynamic binding,

Pages from Programming in Objective-C 2.0 (2nd Edition)-2dataspecifier.png

 

no source code

No comments:

Post a Comment