Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5940783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:01:02+00:00 2026-05-22T16:01:02+00:00

Iobuffer.cpp #include Iobuffer.h IOBuffer::IOBuffer (int maxBytes){ Init (maxBytes); } IOBuffer & IOBuffer :: operator

  • 0

Iobuffer.cpp

#include "Iobuffer.h"

    IOBuffer::IOBuffer (int maxBytes){
    Init (maxBytes);
    }

    IOBuffer & IOBuffer :: operator = (const IOBuffer & buffer){
        if(MaxBytes< buffer.BufferSize) return *this;//fail
        Initialized = buffer.Initialized;
        BufferSize = buffer.BufferSize;
        memcpy(Buffer, buffer.Buffer, buffer.BufferSize);
        NextByte = buffer.NextByte;
        Packing = Packing;
        return *this;
    }

    void IOBuffer::Clear(){
        NextByte = 0;
        Packing = true;
    }

    void IOBuffer::Print(ostream & stream) const{
        stream<<"MaxBytes "<<MaxBytes<<" BufferSize "<<BufferSize;
    }

    int IOBuffer::Init (int maxBytes){
        Initialized = false;
        if (maxBytes < 0) maxBytes = 0;
        MaxBytes = maxBytes;
        Buffer = new char[MaxBytes];
        BufferSize = 0;
        Clear ();
        return 1;
    }

    int IOBuffer::DRead(istream & stream, int recref){
        stream.seekp(recref, ios::beg);
        if(stream.tellp() != recref) return -1;
        return Write(stream);
    }

    static const char * headerStr = "IOBuffer";
    static const int headerSize = strlen(headerStr);

    int IOBuffer::ReadHeader(istream & stream){
        char str[9];
        stream.seekg(0, ios::beg);
        stream.read(str, headerSize);
        if(!stream.good()) return -1;
        if(strncmp(str,headerStr, headerSize)==0) return headerSize;
        else return -1;
}

    int IOBuffer::WriteHeader (ostream & stream) const{
        stream.seekp(0, ios::beg);
        stream.write(headerStr, headerSize);
        if(!stream.good()) return -1;
        return headerSize;
}

its accompanied Iobuffer.h

#include <cstring>
#include <iostream>
    class IOBuffer{
    public:
        IOBuffer (int maxBytes = 1000);
        IOBuffer & operator = (const IOBuffer &);
        virtual void Clear ();
        virtual int Pack (const void * field, int size = -1) = 0;
        virtual int Unpack (void * field, int maxbytes = -1) = 0;
        virtual void Print(ostream &) const;
        int Init (int maxBytes);
        virtual int Read (istream & x) = 0;
        virtual int Write (ostream & x) const = 0;
        virtual int DRead(istream &, int recref);
        virtual int DWrite(ostream &, int recref) const;
        virtual int ReadHeader (istream &);
        virtual int WriteHeader (ostream *);
    protected:
        int Initialized;
        char * Buffer;
        int BufferSize;
        int MaxBytes;
        int NextByte;
        int Packing;
    };

This is an assignment from my File Systems course. In Iobuffer.h, #include <iostream> is there because I supposed it would fix the “ostream” or “istream” “has not been declared” errors I am getting from the virtual; Print, Read, Write, DRead, DWrite, ReadHeader, and WriteHeader function prototypes. Those are the only errors from that file. The errors in the .cpp file correlate somewhat, I get the same “istream” and “ostream have not been declared” errors. Any help is much appreciate, let me know if further detail is needed.

-Macaire

Update, Sir Charlesworth’s suggestion cut down the errors exponentially. In the header file for WriteHeader’s virtual function prototype “candidate is: virtual int IOBuffer::WriteHeader(std::ostream)” error is generated.

The remaining 5 errors are in the .cpp file, three of them from DRead’s definition(one from each line). The first line says

‘struct std::basic_istream<char, std::char_traits<char> >’ has no member named ‘seekp’

On a side note why is that formatting so foreign? I looked up ostream here at cplusplus.com, and I suppose it could be because I am using an integer as my seek offset. Continuing, the following line says

‘struct std::basic_istream<char, std::char_traits<char> >’ has no member named ‘tellp’

The return statement says something that is very curious,

no matching function for call to ‘IOBuffer::Write(std::basic_istream<char, std::char_traits<char> >&)’

The final error is prototype for

‘int IOBuffer::WriteHeader(std::ostream&) const’ does not match any in class ‘IOBuffer’

and yes that was 5 not 6 error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T16:01:03+00:00Added an answer on May 22, 2026 at 4:01 pm

    Most names in the standard library live within the namespace std. So common practice is simply to fully qualify them when you use them (std::ostream instead of ostream, and so on).

    A less recommended approach is to declare using namespace std;, which will pull the entire std namespace into whatever scope you’re currently in (to save you the trouble of writing std:: every time). Note that it is considered extremely bad practice to have using namespace ... declarations in header files. These should be reserved for source files only.

    UPDATE

    The majority of your new error messages are because you’ve confused istream and ostream. istream has a function called seekg, not seekp, for instance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

class BufferFile{ public: BufferFile(IOBuffer &); int Open(char *); int Create(char *); int Close(); int
The following code compiles fine ... int main (int argc, const char * argv[])
char buffer[12] = {Testing! 12}; unsigned long compressedSize; char* compressed = compress(buffer, 12, &compressedSize);
Is there a way to make ibuffer-visit-buffer behave like ido-switch-to-buffer (with raise-frame option)? If
I tried http://rebol.wik.is/Protocols/Test-async-http.r do %async-protocol.r do %async-http.r buffer: copy content-length: 0 handler: func [port
I'm programming a very simple socket server following this sample code . The server
(INBuffer[3] << 8) + INBuffer[2] Is this essentially moving the bit in INBuffer[3] into
I am using the apple example code SpleakHere . in this code there is
Started getting errors with SQL Server 2005 This is the first time i've tested
I'm trying to decrypt an encrypted image in Android using this code: public class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.