Hirdetés

Új hozzászólás Aktív témák

  • Zulfaim

    csendes tag

    class buffer {
    char* buff;
    int size;
    public:
    //buffer() : buff(0), size(0){}
    buffer(int s=10){buff=new char[size=s];}
    buffer(const buffer&);
    buffer& operator=(const buffer&);
    friend ostream& operator<<(ostream& s, const buffer b);
    ~buffer(){ delete[] buff; }

    buffer& buffer::operator=(const char* value)
    {
    delete[] buff;
    if( size=strlen(value))
    {
    buff=new char[size+1];
    strncpy(buff,value,size);
    }
    return *this;
    }

    };
    buffer::buffer(const buffer& e)
    {
    buff=new char[size=e.size];
    for(int i;i<size;i++)
    {
    buff=e.buff;
    }
    }

    buffer& buffer::operator=(const buffer& e)
    {
    if( this!= &e)
    {
    delete[] buff;
    buff=new char[size=e.size];
    for(int i=0;i<size;i++)
    {
    buff=e.buff;
    }
    }
    return *this;
    }

    ostream& operator<<(ostream& s, const buffer b)
    {
    for(int i=0;i<b.size;i++)
    {
    s << b.buff;
    }
    return(s);

    }

    int main()
    {
    buffer b;
    b=''xyz'';
    b+=''-=EZ A BUFFERHEZ FUZOTT RESZ=-'';
    cin.get();
    return 0;
    }


    Ezzel mi a baj?

    [Szerkesztve]

Új hozzászólás Aktív témák