📄 stringcl.h
字号:
//// *****************************************************************// *// * Author : Gerald ( Jerry ) Carter// * cartegw@eng.auburn.edu// * Filename : stringcl.cc// * Date Created : 940401// * Last update : 970219// *// * Description// * -----------// * This file contains all the method defintion for the string// * class from "stringcl.h". Each method is documented individually.// *// *****************************************************************//// INCLUDE FILES#include <iostream.h> // ostream class#include <string.h> // strdup ()#include "logic.h" // boolean typedefs#ifndef _STRINGCL_H // to prevent multiple inclusion#define _STRINGCL_H// MACROS#define MAX_BUF_SIZE 1000 // used in operator/ ()class string { private : char *text; // char* to text string ('\0' terminated) int length; // length of actual characters in string public : // CONSTRUCTORS string (char, int); // allocted string of length int with char in // each position string (char*); // allocated copy of char* string (void); // no text with length = 0 string (const string&); // assigment // DESTRUCTORS ~string (void) // destructor { delete []text; } // OVERLOADED OPERATORS string operator+ (char); // add char to end of string string operator+ (const string&); // catenates 2 strings string operator- (char); // delete all instances of char // in string string operator- (int); // delete char at int position string& operator= (const string&); // assignment operator int operator< (const string&) const; // simple ascii comparison int operator> (const string&) const; // simple ascii comparison int operator== (const string&) const; // simple ascii comparison int operator!= (const string&) const; // simple ascii comparison string operator/ (const char); // returns portion of string // preceding passed character string operator% (const char); // returns portion of string // after passed character // inclusive char& operator[] (int) const; // returns reference to char at // int position friend ostream& operator<< (ostream&, const string&); // get from op friend istream& operator>> (istream&, string&); // put to op operator char* (void) const // cast a string to a char* { return text; } // GENERAL METHODS int StrLength (void) const // return length of string { return length; } char* StrText (void) const // return allocated copy of { return strdup(text); } // string text // static data members static const string empty_string;}; #endif//********** end of stringcl.h ******************************************//***********************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -