2.2.3.15.38 string::string

Description

Default constructor, creates a new empty string object


Constructs a string object from a null-terminated string.


Constructs a string object from a character that is repeated nRepeat times.


Constructs a string object from an array of characters of length nlength, not null-terminated.


Constructs a string object from any _VARIANT type variable which holds a string

Syntax

string( )


string( LPCSTR lpcszSrc )


string( char ch, int nRepeat = 1 )


string( LPCTSTR lpch, int nLength )


string( _VARIANT var )

Parameters

lpcszSrc
[input]A null-terminated string to be copied into this string object.


ch
[input]A single character to be repeated nRepeat times.
nRepeat
[input]The repeat count for ch.


lpch
[input] A pointer to an array of characters.
nLength
[input]length of characters.


var
[input]a _VARIANT object

Return

None.


None.


None.


None.

Examples

EX1

void string_string_ex1()
{
    string str1;  //empty string
	bool bRet = str1.IsEmpty();
	out_int("", bRet)//true
}


EX2

void string_string_ex2()
{
	string str2("cow");  //create from a string literal
	out_str(str2);//"cow"
}


EX3

void string_string_ex3()
{
    string str3('a',6);  
	out_str(str3);//"aaaaaa"
}


EX4

void string_string_ex4()
{
	char * str = "Origin C";
	int nLength = 6;//Set length 6,Only store the first 6 characters of string
	string str4(str,nLength);
	out_str(str4);//"Origin"
}


EX5

void string_string_ex5()
{
   _VARIANT obj;
   string s = "Hello";
   obj = s;
   string str = obj;
}

Remark

See Also

Header to Include

origin.h