0
const and pointer,typedef
2const and Pointer const int *– p is a pointer variable that can hold an address of constintegers– Cannot assign value 9 ...
3const and Pointer const int *– p, which is declared to point to const integers, can also hold anaddress of integer type–...
4const and Pointer int * and const int– p, which is declared to point to normal integers, cannot holdthe address of const...
5const and Pointer int * const– p is a const pointer variable which can point to normalintegers– You cannot change its va...
6const and Pointer const int * const– p is a const pointer variable of const integers, so p can beinitialized once but ca...
typedef Example– Type name is too long– Can we make it shorter?7unsigned short var1 ;unsigned short var2 ;…ushort var1 ;u...
typedef typedef– old name can be consist of many words– But, new name should be consist of one word.8typedef old name new...
typedef Example9typedef int Int ;typedef Int INT ;typedef unsigned long ulong ;void main(){ulong var1 ;Int k ;INT m ;…}
Upcoming SlideShare
Loading in...5
×

12 1. const pointer, typedef

351

Published on

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
351
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "12 1. const pointer, typedef"

  1. 1. const and pointer,typedef
  2. 2. 2const and Pointer const int *– p is a pointer variable that can hold an address of constintegers– Cannot assign value 9 to the variable pointed by p, becausethe variable which p points to is const intconst int a = 7;const int *p = &a; // possiblea = 8 ; // impossible*p = 9 ; // impossible
  3. 3. 3const and Pointer const int *– p, which is declared to point to const integers, can also hold anaddress of integer type– a can not be modified through by p, because p is declared asconst int *• Any variable which is accessed through p is considered as const intint a = 7;const int *p = &a; // possiblea = 8 ; // possible*p = 9 ; // impossible
  4. 4. 4const and Pointer int * and const int– p, which is declared to point to normal integers, cannot holdthe address of const integers– if it is possible, we can change the const variable through p• Eg) *p = 8const int a = 7;int *p = &a; // impossible
  5. 5. 5const and Pointer int * const– p is a const pointer variable which can point to normalintegers– You cannot change its value because it is a const variable– p is a const pointer variable of normal integer, so p cannothold the address of const integersint a = 7, b = 8 ;int * const p = &a; // possiblep = &b; // impossibleconst int a = 7;int * const p = &a; // impossible
  6. 6. 6const and Pointer const int * const– p is a const pointer variable of const integers, so p can beinitialized once but cannot be changed anymoreconst int a = 7, b = 8 ;const int * const p = &a; // possiblep = &b; // impossible*p = 6; // impossibleint a = 7, b = 8 ;const int * const p = &a; // possiblep = &a; // impossible*p = 6; // impossible
  7. 7. typedef Example– Type name is too long– Can we make it shorter?7unsigned short var1 ;unsigned short var2 ;…ushort var1 ;ushort var2 ;…
  8. 8. typedef typedef– old name can be consist of many words– But, new name should be consist of one word.8typedef old name new nametypedef unsigned short ushort ;void main(){ushort var1 ;ushort var2 ;…}
  9. 9. typedef Example9typedef int Int ;typedef Int INT ;typedef unsigned long ulong ;void main(){ulong var1 ;Int k ;INT m ;…}
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×