>注释很少,大家凑合着看吧.</P>
>这是头文件:StrStream.h</P>
>#ifndef STRSTREAM_H$ h$ }; w+ C- n. E& \7 X4 \! z
>//字符流声明& W, E# d: o' \7 J2 A
> //格式化2 `& _# `8 o M: a
> //比较7 o$ y/ M" K! d! o9 ^
> //取得字符串信息' ^- |( f: s4 q
> StrStream & operator+= (char *str); //*3 h7 h& m; }" g4 Y( Z
> bool operator== (char *str); //*3 ]# d4 N4 j0 O9 r, l: Q
> bool operator!= (char *str); //*
> bool operator > (char *str); //*5 O8 b# a7 e6 ^$ _
> bool operator>= (char *str); //*
>#endif//STRSTREAM_H</P>4 k5 o) g0 b0 g( r6 ?
>////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////( @: P% X) j# `' a% O: c) o+ n2 \3 u
>#include "StrStream.h"
>StrStream::StrStream() l( @( w- S% o
>StrStream::StrStream(char*str) g* g. y) O1 f! T2 N" G
>StrStream::StrStream(StrStream &str): s* A' \% a. w
>StrStream::~StrStream()
>void StrStream::Set(char *str)
> //如果串不空
> //如果源串空5 [; `# j% d v/ {* ?, f
> //拷贝串
> m_Len=len;</P>
> m_Empty=false;
>char* StrStream::Get()$ A. W3 a! G$ {+ p! P
>void StrStream::Clear()
>char*StrStream::c_str()! @4 b% q4 e' [, Z- I4 B
>int StrStream::GetLength()
> return m_Len;. h4 [- H8 V' |
ength()
perator = (char *str)
perator = (StrStream &str)8 k" l0 h( Y8 j0 Q
perator +=(char *str)& K, j$ I% x( _- r6 D; K
perator +=(StrStream &str)
perator ==(char *str)3 u( h: Q$ K) s+ p4 f% ]
perator ==(StrStream &str)- i& z D& L$ M1 ]# B0 @1 G
perator !=(char *str)
perator !=(StrStream &str)
perator < (char *str)! t6 H ^# g8 a2 Z8 @
perator < (StrStream &str)
perator > (char *str)
perator > (StrStream &str)
perator <=(char *str)
perator <=(StrStream &str)
perator >=(char *str)
perator >=(StrStream &str)
elete(int pos,int num)
>大家还是看源文件吧.这上面的代码贴的不是太整齐:我把源文件传上来吧!</P>[attach]687[/attach]
2.32 KB, 下载次数: 0, 下载积分: 体力 -2 点
本人写的一字符流类
>写字符流时的测试程序:</P><
>StrStream str;6 \# Q$ _% v7 P1 O
> cout<<str.Length()<<endl;
> str+=" ";. \6 G0 L4 V/ w3 e
> str=" 我是中国人,不吃外国饭!";
> str=" 我是中国人,不吃鬼子饭,鬼子给我滚蛋 ";
> str="97";| 欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) | Powered by Discuz! X2.5 |