C++ operator T* - CSmartPtr
In This Topic
operator T*()
operator T*() const
operator const T*() const
|
|
Property |
Description |
|
|
|
Returns |
A pointer to the underlying object held in the smart pointer |
|
|
|
Description |
Cast operator, automatically casts the smart pointer to the type of object T. |
|
|
|
Remarks |
automatically invoked when passing smart pointers to methods that take a non-smart pointer. |
|
|
|
Example |
class CElmSequence : ...
{
public:
void SetBasicElement(ElmSequence::CBasicElement* value);
...
}
try
{
// create an instance of the class to load the XML file into
ElmSequence::CElmSequencePtr spElm = ElmSequence::CElmSequence::CreateInstance();
ElmSequence::CBasicElementPtr spBasElm = ElmSequence::CBasicElement::CreateInstance();
spElm->SetBasicElement(spBasElm);
spElm->GetBasicElement()->SetStringElm(_T("Test Data"));
}
catch (CLtException& e)
{
// Note : exceptions are likely to contain inner exceptions
// that provide further detail about the error, GetFullMessage
// concatantes the messages from them all.
_tprintf(_T("Error - %s\n"), e.GetFullMessage().c_str());
}
|
|