Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7610323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:23:27+00:00 2026-05-31T01:23:27+00:00

In java, we can define different interfaces and then later we can implement multiple

  • 0

In java, we can define different interfaces and then later we can implement multiple interface for a concrete class.

// Simulate Java Interface in C++
/*
interface IOne {
    void   MethodOne(int i);
    .... more functions
}

interface ITwo {
    double MethodTwo();
    ... more functions
}

class ABC implements IOne, ITwo {
    // implement MethodOne and MethodTwo
}
*/

In C++, generally speaking, we should avoid the usage of multiple inheritance, although multi-inheritance does have its edge on some situations.

class ABC {
public:
    virtual void   MethodOne(int /*i*/) = 0 {}
    virtual double MethodTwo() = 0 {}

    virtual ~ABC() = 0 {}

protected:
    ABC() {} // ONLY ABC or subclass can access it
};

Question1> Based on the design of ABC, should I improve any other things in order to make it a decent ABC?

Question2> Is it true that a good ABC should not contain member variables and instead variables should be kept in the subclasses?

Question3> As I indicated in the comments, what if ABC has to contain too many pure functions? Is there a better way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T01:23:29+00:00Added an answer on May 31, 2026 at 1:23 am
    1. Do not provide an implementation for pure virtual methods unless it is necessary.
    2. Do not make your destructor pure virtual.
    3. Do not make your constructor protected. You cannot create an instance of an abstract class.
    4. Better hide an implementation of constructor and destructor inside a source file not to pollute other object files.
    5. Make your interface non-copyable.

    If this is an interface, better do not have any variables there. Otherwise it would be an abstract base class and not an interface.

    Too many pure functions is OK unless you can do it with less pure functions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Java, you can define an interface as a class with no actual code
In Java you can define generic class that accepts only types that extend a
In Java, you can define multiple top level classes in a single file, providing
I have a programming problem in Java: Can I define a different method for
In Java, I'd like to be able to define marker interfaces, that forced implementations
I like how Java has a Map where you can define the types of
The Java JCR API defines a persistence mechanism which can be used to replace
In Java can I create a URI for a file located locally in the
Is there anything simple Java can't do that can be done in a similar
I want to learn to write a thread pool in Java Can anyone point

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.