what is it? operator? function? a type redefine?

Started by
6 comments, last by stroma 18 years, 10 months ago
what is LPCTSTR CString::operator LPCTSTR operator LPCTSTR ( ) const; Return Value A character pointer to the string's data.
Advertisement
LPCSTR is a windows type namely a "Long Pointer (to) C String" i.e. a char*.
and the operator is a conversion operator, that let's you automagicly get a LPCSTR from a CString so you can use it convieniently with functions taking char*.

Hope that answers your question.
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats
you mean conversion is one kinds of operator??
Quote:Original post by derek7
you mean conversion is one kinds of operator??


What I mean is that you can define own conversion operators for classes and it's sometimes convinent todo so. I guess the most familiar is conversion to bool for streams that lets you write code like:
Thing thing;while( std::cin >> thing)  DoStuffWith( thing);
;
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats
Quote:Original post by DigitalDelusion
Quote:Original post by derek7
you mean conversion is one kinds of operator??


What I mean is that you can define own conversion operators for classes and it's sometimes convinent todo so. I guess the most familiar is conversion to bool for streams that lets you write code like:
Thing thing;while( std::cin >> thing)  DoStuffWith( thing);
;



I mean << is a operator just like + = * ...

but a conversion is a operator too.? like (char*)
Quote:Original post by derek7
but a conversion is a operator too.? like (char*)


Yes. A conversion can either go through a conversion constructor (i.e. any non-explicit one-parameter constructor like Foo::Foo(Bar) ) or through a conversion operator (e.g. Bar::operator Foo()).
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Quote:Original post by DigitalDelusion
LPCSTR is a windows type namely a "Long Pointer (to) C String" i.e. a char*.


Almost. I'm pretty sure the actual typedefs are as follows:

LPSTR - char*
LPCSTR - const char*
LPWSTR - wchar_t*
LPCWSTR - const wchar_t*

LPTSTR and LPCTSTR are either defined as LPSTR/LPCSTR or LPWSTR/LPCWSTR depending on whether you're building in Unicode mode or not.

if you are using visual c++ (i dont know if others supports) you can right click the data type and click on "Go to Definition". that will show you the meaning of data type.
but there are some tipsto know it, like it starts with LP so it is a long pointer...etc
+-+-+-+-+-STR

This topic is closed to new replies.

Advertisement