Jump to content
  • Advertisement
Sign in to follow this  
armond

What is the bottomline of polymophism in C++ as opposed to Java interfaces?

This topic is 4562 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In one book said that interfaces is the poly in polymorphism, the abs in abstract class, and the caffeign in java. So what's C++ answer to this?

Share this post


Link to post
Share on other sites
Advertisement
A class with no members and only pure virtual methods is usually considered as an interface in C++. Just because it has no specific keyword for it, it doesn't mean it doesn't exist.

Illco

Share this post


Link to post
Share on other sites
Quote:
Original post by armond
In one book said that interfaces is the poly in polymorphism, the abs in abstract class, and the caffeign in java. So what's C++ answer to this?


multiple inheritance?

otherwise interfaces are just classes with all functions pure virtual, and no instance members defined...

Share this post


Link to post
Share on other sites
Java:

public interface Something
{
public abstract void doStuff();
public abstract int getStuff();
}



C++:

class Something
{
public:
virtual void doStuff() = 0;
virtual int getStuff() = 0;
};



Pretty much the same thing.

Share this post


Link to post
Share on other sites
Quote:
Original post by armond
In one book said that interfaces is the poly in polymorphism, the abs in abstract class, and the caffeign in java.


Get a new book. Anything that uses cliched lines like that is crap by default.

Share this post


Link to post
Share on other sites
Stompy - or if you're lazy like me:

struct Something {
virtual void doStuff() = 0;
virtual int getStuff() = 0;
};

[wink]

Share this post


Link to post
Share on other sites
Quote:
Original post by joanusdmentia
Get a new book. Anything that uses cliched lines like that is crap by default.

Quoted For Emphasis.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!