StrBuf::Set( const StrPtr & )

Set a StrBuf from a reference of a StrPtr. Arguments are commonly instances of classes derived from the StrPtr class, such as StrRef and StrBuf.

Virtual?

No

 

Class

StrBuf

 

Arguments

const StrPtr &s

reference of the StrPtr instance

Returns

void

 

Notes

Initialize the StrBuf and the StrPtr before calling Set().

Any memory allocated for the StrBuf's buffer is separate from the memory for the StrPtr's buffer.

Example

#include <iostream>

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

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

    sr.Set( "xyz" );
    sbt.Set( sr );    // set StrBuf from StrRef

    cout << "sr.Text() returns \"" << sr.Text() << "\"\n";
    cout << "sbt.Text() returns \"" << sbt.Text() << "\"\n\n";

    sbs.Set( "abc" );
    sbt.Set( sbs );   // set StrBuf from StrBuf

    cout << "sbs.Text() returns \"" << sbs.Text() << "\"\n";
    cout << "sbt.Text() returns \"" << sbt.Text() << "\"\n";
}

Executing the preceding code produces the following output:

sr.Text() returns "xyz"
sbt.Text() returns "xyz"

sbs.Text() returns "abc"
sbt.Text() returns "abc"