English 中文(简体)
函数和类错误
原标题:Function and Class errors
  • 时间:2011-05-23 05:29:22
  •  标签:
  • c++
  • buffer
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);  
    }  

我从IOBuffer字段中得到了几个错误,说它在“~&;”之前没有在函数范围中声明或“预期”)™ token”,是什么导致了这些问题?

Here are all the files involved in this project: Person.h!
Buffile.cpp
BuffFile.h
Delim.cpp
Delim.h
Fixfld.cpp
Fixfld.h
FixLen.cpp
FixLen.h
Iobuffer.cpp
Iobuffer.h
Length.cpp Length.h
Varlen.cpp
Varlen.h

最佳回答

我认为你的问题是(来自Buffile.h):

#ifndef IOBUFFER
#define IOBUFFER
#include "Iobuffer.h"
#endif

…该逻辑打破了Iobuffer中的类似/冗余逻辑。h:

#ifndef IOBUFFER
#define IOBUFFER
class IOBuffer{
[...]
#endif

问题是,IOBuffer.h中“类IOBuffer”的声明从未被解析,因为编译器值IOBuffer已经在Buffile.h中定义,因此IOBuffer.h顶部的#ifndef IOBuffer没有被激活。

正确的方法是修改Buffile.h,使其仅包含#include“Iobuffer.h”行,并由Iobuffer.h的内容来执行#ifndef和#define内容。

问题回答

暂无回答




相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签