mirror hosted by tehsausage.com
PTypes: string: constructors/destructors

C++ Portable Types Library (PTypes) Version 2.1


Top: Basic types: string: Constructors/destructors

#include <ptypes.h>

class string {
    string();
    string(const string&);
    string(char);
    string(const char*);
    string(const char*, int);
    ~string();
}

A string object can be constructed in 5 different ways:

Destructor ~string() decrements the reference count for the given string buffer and removes it from the dynamic memory if necessary.

Examples:

string s1;             // empty string
string s2 = s1;        // copy
string s3 = 'A';       // single character
string s4 = "ABCabc";  // string literal
char* p = "ABCabc";
string s5 = p;         // null-terminated string
string s6(p, 3);       // buffer/length

See also: Operators, Typecasts, Manipulation, Conversion


PTypes home