⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 head.h

📁 一个关于标准string类的C++程序
💻 H
字号:
#ifndef STRING1_H
#define STRING1_H


#include <iostream>

//using namespace std;
using std::ostream;
using std::istream;

class String {
	friend ostream &operator<<( ostream &, const String & );
	friend istream &operator>>( istream &, String & );

public:

	String(const char * = "" );
	String(const String & );
	~String();

	const String &operator=( const String & );
	const String &operator+=( const String & );

	bool operator!() const;
	bool operator==( const String & ) const;
	bool operator<(const String & ) const;

	//test s1 != s2
	bool operator!=( const String & right ) const
	{
		return !( *this == right );

	}

	//test s1>s2
	bool operator>( const String &right ) const
	{
		return right < *this;

	}

	//test s1<=s2
	bool operator<=(const String &right ) const
	{
		return !(right < *this );

	}

	//test s1>=s2
	bool operator>=( const String &right ) const
	{
		return !(*this < right );

	} 
	//end function operator

	
	char &operator[]( int );
	const char &operator[]( int ) const;

	String operator()( int, int );

	int getLenth() const;

private:
	int length;
	char *sPtr;

	void setString( const char * );

};

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -