pointer declaration
-
1. what are the differences among: CString* str; , CString *str; and (CString*) str; ?! 2. what are LPVOID,LPCTSTR,LPTSTR,LPARAM... (u may give me a link) thx
These two mean the same thing:
CString* str;
CString *str;Since whitespace is not important, they have the identical meaning. The first one is more common among C++ programmers, while the second way is more common among old-school C programers. This:
(CString*) str;
is not a declaration at all. It's an expression statement that casts
str
toCString*
and then throws away the result. --Mike-- LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ | You Are Dumb Magnae clunes mihi placent, nec possum de hac re mentiri. -
1. what are the differences among: CString* str; , CString *str; and (CString*) str; ?! 2. what are LPVOID,LPCTSTR,LPTSTR,LPARAM... (u may give me a link) thx
1. There is no difference between the first and second declarations, but the third, you are casting str, whatever it is, as a CString and therefore is dissimmilar. 2. Those are data types that are all pointers to established types. LPVOID is a pointer to any type of data. LPCTSTR translates to an LPCWSTR (constant null-terminated string of 16-bit Unicode characters) if UNICODE is defined, else it defaults to constant null-terminated 8-bit Windows ANSI characters, in other words, if UNICODE is define, you'll get a wider string. LPARAM is a message parameter. I paraphrased from a Windows Data Types page in this Visual Studio .NET help file, not a website. If anyone wants to correct something or add, be my guest.
-
1. what are the differences among: CString* str; , CString *str; and (CString*) str; ?! 2. what are LPVOID,LPCTSTR,LPTSTR,LPARAM... (u may give me a link) thx
i think the two replies above this one has done question 1 enough justice. as for LPVOID, LPCTSTR, LPTSTR, LPARAM and so on... they are Microsoft defined macros of otherwise basic types... think of it this way.... L = LONG = long P = represents the * (pointer) LP = pointer of size long VOID = void C = const T = TCHAR TCHAR = char or wchar_t depending on if the UNICODE macro is defined STR = string PARAM = parameter so LPVOID is just (long) pointer to void/anything LPCTSTR is just a (long) pointer to a const string of type TCHAR for more Microsoft defined types lookup "Windows Data Types" Cheers
-
i think the two replies above this one has done question 1 enough justice. as for LPVOID, LPCTSTR, LPTSTR, LPARAM and so on... they are Microsoft defined macros of otherwise basic types... think of it this way.... L = LONG = long P = represents the * (pointer) LP = pointer of size long VOID = void C = const T = TCHAR TCHAR = char or wchar_t depending on if the UNICODE macro is defined STR = string PARAM = parameter so LPVOID is just (long) pointer to void/anything LPCTSTR is just a (long) pointer to a const string of type TCHAR for more Microsoft defined types lookup "Windows Data Types" Cheers
Actually, LPVOID and PVOID are the same thing. The L doesn't mean anything any more, and is simply a hangover from the 16-bit DOS/Windows days. Back then:
- PVOID was a NEAR pointer that pointed to an address in the same segment and required 16 bits of storage
- LPVOID was a FAR pointer that could point to anywhere in the memory address space and required 32 bits of storage
Under Win32, there is no concept of NEAR and FAR pointers since the address space is a flat 32-bit address space and segments are not required.
Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
i think the two replies above this one has done question 1 enough justice. as for LPVOID, LPCTSTR, LPTSTR, LPARAM and so on... they are Microsoft defined macros of otherwise basic types... think of it this way.... L = LONG = long P = represents the * (pointer) LP = pointer of size long VOID = void C = const T = TCHAR TCHAR = char or wchar_t depending on if the UNICODE macro is defined STR = string PARAM = parameter so LPVOID is just (long) pointer to void/anything LPCTSTR is just a (long) pointer to a const string of type TCHAR for more Microsoft defined types lookup "Windows Data Types" Cheers
Sawjai wrote: i think the two replies above this one has done question 1 enough justice. as for LPVOID, LPCTSTR, LPTSTR, LPARAM and so on and i'd conclude by saying :
typedef void* LPVOID;
typedef const TCHAR* LPCTSTR;
typedef TCHAR* LPTSTR;
typedef DWORD LPARAM;
//...
#ifdef _UNICODE
#define TCHAR wchar_t;
#else
#define TCHAR char;
#endif
TOXCCT >>> GEII power
[toxcct][VisualCalc]