You will need to print out the pointer address in many scenarios. Take a look at the following output:
CObject*Pobject
=NewCObject;
STD::cout
<<Pobject
<<STD::Endl;
This prints out the POBJEDCT address of the pointer directly. But the output below Char*ptr
="ABC";
STD::cout
<<ptr
<<STD::Endl;Direct Output string: "abc", which is why? Wait a moment. void*pVoid
=ptr;
STD::cout
<<pVoid
<<STD::Endl;This allows you to output the pointer address directly. Presumably, why is it such a manifestation? Actually, it's all becauseoperator<< behavior caused by overloading. Std::cout is std::Ostream an object, in the implementation of Ostream, the string pointer is overloaded with global functions, and the prototype is implemented in VS2008:Template<class_traits>inlineBasic_ostream<Char, _traits>&__clrcall_or_cdecl operator<<(Basic_ostream<Char, _traits>&_ostr ,Const Char
*_val)Other print pointers: ostream member functions:_myt&__clr_or_this_calloperator<< (Const void
*_val)CObject*Pobject implicitly converts the address that the print output pointer points to
C + + print output pointer