questionsolved  Weird syntax error

JRevor (119)   Link to this post
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
Bazzy (4111)   Link to this post
It should work, do you have some other code with that?
JRevor (119)   Link to this post
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
JRevor (119)   Link to this post
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
JRevor (119)   Link to this post
Found the error. The code was missing this line
 
using namespace std;
Bazzy (4111)   Link to this post
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
JRevor (119)   Link to this post

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

This topic is archived - New replies not allowed.