windows-nt/Source/XPSP1/NT/com/rpc/perf/splay/string.hxx
2020-09-26 16:20:57 +08:00

75 lines
2 KiB
C++
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//+-------------------------------------------------------------------------
//
// Microsoft Windows
//
// Copyright (C) Microsoft Corporation, 1994 - 1999
//
// File: string.hxx
//
//--------------------------------------------------------------------------
//
//
// Filename: String.hxx
//
// Description: contains a basic string class
//
// Author: Scott Holden (t-scotth)
//
//
#include <iostream.h>
#include <string.h>
class String
{
private:
char *_string;
unsigned int _length;
public:
String( ) : _string( NULL ), _length( 0 ) { }
String( const char * );
String( const String& );
~String( )
{
if ( _string ) {
delete[] _string;
}
}
char& operator[]( int );
const char& operator[]( int ) const;
String& operator=( const String& );
String& operator=( const char * );
friend ostream& operator<<( ostream&, const String& );
friend istream& operator>>( istream&, String& );
friend int operator==( const String &x, const char *s )
{ return ( strcmp( x._string, s ) == 0 ); }
friend int operator==( const String &x, const String &y )
{ return ( strcmp( x._string, y._string ) == 0 ); }
friend int operator!=( const String &x, const char *s )
{ return ( strcmp( x._string, s ) != 0 ); }
friend int operator!=( const String &x, const String &y )
{ return ( strcmp( x._string, y._string ) != 0 ); }
friend int operator<( const String &x, const char *s )
{ return ( strcmp( x._string, s ) < 0 ); }
friend int operator<( const String &x, const String &y )
{ return ( strcmp( x._string, y._string ) < 0 ); }
friend int operator>( const String &x, const char *s )
{ return ( strcmp( x._string, s ) > 0 ); }
friend int operator>( const String &x, const String &y )
{ return ( strcmp( x._string, y._string ) > 0 ); }
};