StrRef::Set( const StrPtr & )

Set a StrRef to reference an existing StrPtr.

Virtual?

No

 

Class

StrRef

 

Arguments

const StrPtr &s

the StrPtr to reference

Returns

void

 

Notes

StrRef::Set() does not copy the target string; it simply establishes a pointer to it. Be sure that the StrRef pointing to the target string does not outlive the target string.

Example

#include <iostream>

#include <stdhdrs.h>
#include <strbuf.h>

int main( int argc, char **argv )
{
    StrBuf str1;
    StrRef sr;

    str1.Set ( "xyz" );
    sr.Set( str1 );

    cout << "str1 = \"" << str1.Text() << "\"\n";
    cout << "sr.Text() returns \"" << sr.Text() << "'\"n";
}

Executing the preceding code produces the following output:

str1 = "xyz"
sr.Text() returns "xyz"