c - Different typedef for same information -
i working on piece of code , encountered :
typedef jobject jthread; typedef jobject jthreadgroup;
what significance of different typedef similar entry ?
it allows have 2 different names same type. there (at least) 2 different reasons you'd want this:
- in code, want reader see type of data we're dealing with. after all, "thread" diffferent "group of threads", if underlying type representing them different.
- ability change type 1 of types without affecting other. if @ later stage, decide "jthreadgroup" better new type, can change without affecting "jthread".
imagine have small game, count score in integer type. have count of players:
typedef int scorecount; typedef int playercount;
later on, decide need small number, short
count players:
typedef short playercount;
same idea using "jobject", different base-type, possibly make easy understand.
Comments
Post a Comment