Weird syntax error

My lecturer wrote this code
1
2
3
4
class IOBuffer {
  public:
    virtual TPointer Read(fstream& fs) = 0;
};


Error `Read' declared as a `virtual' field. Expected `;' before '(' token, expected unqualified-id before '=' token .

What is going on here?
Last edited on
It should work, do you have some other code with that?
Here's a bit more of the code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class IOBuffer {
  protected:
    char Buffer[MAXBYTES];
    TSize BufferSize;
    TSize MaxBytes;
    TSize NextByte;
    int _Format;
  public:
    IOBuffer(): MaxBytes(MAXBYTES), BufferSize(0), NextByte(0){}
    virtual TPointer Read(fstream& fs) = 0;
    virtual TPointer Write(fstream& fs) const = 0;
    virtual TSize Pack(const void* field, TSize size = -1) = 0;
    virtual TSize UnPack(void* field, TSize size = -1) = 0;
    virtual void Clear(void) {BufferSize = NextByte = 0;}
    virtual TSize Length(void) const {return(BufferSize);}
    void ResetB(void) { // Resets NextByte
       NextByte = 0;
       return;
    }
    int Format(void) {return _Format;}
};

//IOBuffer <--->HD
class VarLenBuffer: public IOBuffer {
  public:
    virtual TPointer Read(fstream& fs);
    virtual TPointer Write(fstream& fs) const;
};

//This is implemented in a .cpp file
//there are many other methods like this


   TPointer VarLenBuffer::Read(fstream& fs){
      TPointer pos = fs.tellg();
      Clear();
      fs.read((char*)& BufferSize,sizeof(TSize));
      fs.read(Buffer, BufferSize);
      return pos;
   }


Last edited on
This is just a portion of the code. The code itself is way bigger.
TPointer was declared already in the beginning
1
2
3
4
5
typedef long TPointer;
typedef int TSize;
const int MAXBYTES = 1000;
const long PNULL = -1;


EDIT :(the message this was an answer to was deleted)
Last edited on
Found the error. The code was missing this line
 
using namespace std;
I tried that in g++ 4.4 but it doesn't complain.
Which compiler / options are you using?
Do you get other error messages?

EDIT :(the message this was an answer to was deleted)
What?


[Edit]
Found the error. The code was missing this line
OK
Last edited on

EDIT :(the message this was an answer to was deleted)

This is what i meant to say: That post in particular was an answer to other post, which was deleted right after i posted a reply.
Sorry for my bad english, and thanks
Topic archived. No new replies allowed.