470,855 Members | 1,251 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,855 developers. It's quick & easy.

Interfaces in c++

dex
hi,
i am just trying to implement Iterator pattern in C++, I just stuck up
with how to use interfaces,
Please help me in how to use interfaces in C++,
Can i use abstract base class instead of interfaces?
thanks,
Dex

Mar 1 '06 #1
2 1628

dex wrote:
hi,
i am just trying to implement Iterator pattern in C++, I just stuck up
with how to use interfaces,
Please help me in how to use interfaces in C++,
Unlike Java, C++ doesnot support the keyword "interface"

Can i use abstract base class instead of interfaces?


Yes, in C++ you can use ABCs.

Mar 1 '06 #2
dex wrote:
hi,
i am just trying to implement Iterator pattern in C++, I just stuck up
with how to use interfaces,
Please help me in how to use interfaces in C++,
Can i use abstract base class instead of interfaces?


More precisely, you can use multiple inheritance in C++ in much the
same way that interfaces are used in Java. The idea would be to declare
an abstract base class (or non-abstract class when following the
non-virtual interface (NVI) design pattern). Then simply have classes
conforming to the "interface" inherit from the class designed in the
previous step, regardless of any other classes they may also inherit
from. (hmmm...I wonder if I could have made that last sentence any
longer...)

Greg

Mar 1 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by baylor | last post: by
30 posts views Thread by Frank Rizzo | last post: by
8 posts views Thread by John | last post: by
9 posts views Thread by Sean Kirkpatrick | last post: by
22 posts views Thread by RSH | last post: by
18 posts views Thread by Tony | last post: by
10 posts views Thread by hyperboreean | last post: by
23 posts views Thread by A.Gallus | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.