Need some help with errors, culmination of a File

2019-09-21 08:34发布

问题:

class BufferFile{
public:
BufferFile(IOBuffer &);
int Open(char *);
int Create(char *);
int Close();
int Rewind();
int Read(int recaddr = -1);
int Write(int recaddr = -1);
int Append();
IOBuffer & GetBuffer();
protected:
IOBuffer & Buffer;
std::fstream File;
int HeaderSize;
int ReadHeader();
int WriteHeader();
};

BufferFile::BufferFile(IOBuffer & from):Buffer(from){}    

int BufferFile::Read(int recaddr){  
    if(recaddr==1) return Buffer.Write(File);  
    else return Buffer.DWrite(File, recaddr);  
}  

int BufferFile::Append(){  
    File.seekp(0,std::ios::end);  
    return Buffer.Write(File);  
}  

IOBuffer & BufferFile::GetBuffer(){  
    return Buffer;  
}  

int BufferFile::ReadHeader(){  
    return Buffer.ReadHeader(File);  
}  

int BufferFile::WriteHeader(){  
    return Buffer.WriteHeader(File);  
}  

I am getting several errors form the IOBuffer field, saying that it was not declared in the function scopes or "expected `)' before ‘&’ token" on the constructor.

Any help is appreciated

回答1:

Several of the errors mention that class IOBuffer has no member named "pack". The message is absolutely correct, it doesn't; if you look at the header, it has a method named Pack, with a capital P. C++ is case-sensitive!

The errors about "redefinition" are happening because your include files don't have include guards to prevent them from being included multiple times -- you need to fix that.

That leaves only a few errors remaining; when you've got everything down to those last few, come back and talk to us again. This time, no images! No links! Just paste the actual text of the error message, and the few lines of code where the errors occur, and somebody will be able to help you.



标签: c++ buffer