class B : virtual public A

C

Chameleon

I read "thinking in C++" but I don't understand how the pointers stored
in vtable of SeekableInputOutputStream.
Can you explain me the order please?

Thanks a lot!
---------------------------------------
class InputStream
{
public:
virtual int read(void *base, int size) = 0;
};

class OutputStream
{
public:
virtual int write(void *base, int size) = 0;
};

class Seekable
{
public:
virtual bool seek(int pos, char* origin) = 0;
virtual int size() = 0;
};

class SeekableInputStream : public InputStream, virtual public Seekable {}

class SeekableOutputStream : public OutputStream, virtual public Seekable {}

class SeekableInputOutputStream : virtual public SeekableInputStream,
virtual public SeekableOutputStream {}
--------------------------------------
 
C

Chameleon

Sorry!

Instead of
class SeekableInputOutputStream : virtual public SeekableInputStream,
virtual public SeekableOutputStream {}
use
class SeekableInputOutputStream : public SeekableInputStream, public
SeekableOutputStream {}
 
V

Victor Bazarov

Chameleon said:
I read "thinking in C++" but I don't understand how the pointers
stored in vtable of SeekableInputOutputStream.
Can you explain me the order please?

Why do you care? 'vtable' is an implementation detail. When
writing C++ code you needn't concern yourself with those.

If you do need to know the implementation details like that, you
should consider posting to the newsgroup for your compiler. There
is also "Inside the C++ Object Model" book by Stanley B. Lippman,
check it out.

V
 
S

Simon G Best

Hello!
I read "thinking in C++" but I don't understand how the pointers stored
in vtable of SeekableInputOutputStream.
Can you explain me the order please?

What vtable? vtables aren't part of C++. An /implementation/ of C++
/might/ use vtables, but you don't need to worry about that (unless
you're, say, a compiler developer). Even if your implementation of C++
happens to use vtables, you shouldn't need to worry about the details.
Why do you want to know about vtables?

Simon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top