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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:17:17+00:00 2026-05-16T04:17:17+00:00

Hello :) i would like to ask, if it’s posible to make something like

  • 0

Hello 🙂 i would like to ask, if it’s posible to make something like this:

i have base class (parent) A and three other classes (childs) B C D
in class A, i have virtual functions, that’s ok.
but what if i need a virtual class ?

class A 
{
public:
    virtual int func1()=0;
    virtual int func2()=0;

    virtual class AB; // !!!!???
};

class B
{
public:
    int func1();
    int func2();

    class AB
    {
    public:
    ....
    };
};

classes B C D are same as class B. Now, i would like to create class instance and it should automaticly “redirect” class to instance of B or C D etc like functions.

is it possible ? i hope, you understand 🙂 Thank you very much for answer.

  • 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-16T04:17:18+00:00Added an answer on May 16, 2026 at 4:17 am

    This is fundamentally impossible. A virtual function call is determined at runtime. A class changes the behaviour of the program at compile-time. You can’t make a compile-time determination at runtime unless runtime and compiletime are the same time, i.e. using a JIT or other dynamic code generators. In standard C++, this is impossible.

    What you CAN do is have a base class AB, with a virtual function that creates a class that is guaranteed to inherit from this base class, and then return a pointer to that.

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

Sidebar

Related Questions

This has always confused me. It seems like this would be nicer: ["Hello", "world"].join("-")
Hello I Would like to know how to make somthing that looks like Glass
I would like to do something like: function func($var1 = 'Hello', $var2 = {$var1}
Hello I would like to ask your help regarding javascript code, how do I
Hello I would like to have my app pick a randome XIB file to
I have a simple web service operation like this one: [WebMethod] public string HelloWorld()
I have done this: $ z() { echo 'hello world'; } How do I
Possible Duplicate: JavaScript: Why the anonymous function wrapper? I would like to ask you
I would like to split the string: Hello[You]All to the following array: H,e,l,l,o,[You],A,l,l I
Sorry if this is a dumb way to ask this... I have a generic

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.