📄 string2.h
字号:
// string2.h -- fixed and augmented string class definition
#include <iostream>
using std::ostream;
using std::istream;
#ifndef STRING2_H_
#define STRING2_H_
class String
{
private:
char * str; // pointer to string
size_t len; // length of string
static const int CINLIM; // cin input limit
public:
// constructors and other methods
String();
String(const char * s); // constructor
String(const String & s); // copy constructor
~String();
size_t length()const { return len; }
void stringlow(); // string change to lower
void stringup(); // string change to upper
int has(const char & c)const;
// overload operator methods
String & operator= (const String & s);
String & operator= (const char * s);
char & operator[] (int i);
const char & operator[] (int i)const;
String operator + (const String & st);
String operator + (const char * st);
// overload operator friends
friend bool operator< (const String &st1, const String &st2);
friend bool operator> (const String &st1, const String &st2);
friend bool operator==(const String &st1, const String &st2);
friend ostream & operator<< (ostream & os, const String & st );
friend istream & operator>> (istream & is, String & st);
friend String operator + (const char * st1, const String & st2);
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -