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 7909991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:40:53+00:00 2026-06-03T12:40:53+00:00

I have a problem that I have not yet tested/compiled and wondering if it

  • 0

I have a problem that I have not yet tested/compiled and wondering if it is possible and if it is bad design?

My Problem:

I want to have an abstract base class A and a abstract derived class B.

I realize if this is possible I will have a number of pure virtual member functions in each class and also I will not be able to initialize these objects, but that is a given for abstract classes.

In my design I will have another derived class C which I would then initialize – class C would be derived from class B.

I would have something that looked like this

class C
  ^
  |
abstract class B
  ^
  |
abstract base class A

My Question:

Is this possible first of all? I would suspect so, but not declaring the pure virtual functions in A in class B may be troublesome?

e.x.

class A {
  public:
    virtual void test()=0;
 };

class B: public A {
  public:
   virtual void test()=0;
   virtual void anotherTest()=0;
 };

Is the above okay?

Is this bad c++ design? In future I will have derived classes from A so it would be nice to have this design.

  • 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-06-03T12:40:58+00:00Added an answer on June 3, 2026 at 12:40 pm

    Nothing wrong with it, and it will certainly work. Example follows

    stefanos-imac:dftb borini$ more test.cpp 
    #include <iostream>
    class A {
    public:
        A(void) { std::cout << "A" << std::endl; } 
    
        virtual void method1() = 0;
    };
    
    class B : public A {
    public:
        B(void) : A() { std::cout << "B" << std::endl; }
    
        virtual void method2() = 0;
    };
    
    class C : public B {
    public:
        C(void) : B() { std::cout << "C" << std::endl; }
    
        virtual void method1() { std::cout << "method1" << std::endl; }
        virtual void method2() {std::cout << "method2" << std::endl; }
    };
    
    int main() {
        C c;
        c.method1();
        c.method2();
    }
    stefanos-imac:dftb borini$ ./a.out 
    A
    B
    C
    method1
    method2
    

    Thank you for reminding me that I can still type basic C++.

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

Sidebar

Related Questions

I have this problem that i want to transfer specific ( yet not that
I have a problem with SQL that I have not yet found a solution
I have a problem that I have not seen addressed in this particular way
I have a problem that I have not faced before: It seems that the
I have the odd problem that I am not able to open the properties
I have a strange problem that I could not solve. When I try to
I have a problem that someone introduced a bug but I do not know
I have a problem that happens in IE 8 and Firefox 6.0 but not
Here is a hum-dinger of a problem that I have not found an answer
I have a problem with nodejs and connect and the fact that it's not

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.