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

  • Home
  • SEARCH
  • 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 6111471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:38:03+00:00 2026-05-23T14:38:03+00:00

Say I have a bunch of code for all controls, yet I need subclasses

  • 0

Say I have a bunch of code for all controls, yet I need subclasses that interact with my software suite to use those common methods. I really want my subclass to derive from the control, not the class with the common code. (A MyEdit should derive from Edit, not from MyControl). Also, the suite interacts with controls using an interface which MyControl derives from. In order to do this in C++, I would use multi-inheritance like so

class MyEdit : public Edit, public MyControl;
class MyControl : public IControl;

However, I suddenly discover that I shouldn’t use multi-inheritance if I want some controls to be C# which doesn’t support multi-inhertiance.
So I thought I could do this…

class MyEdit : public MyControl<Edit>;
template class MyControl<Type> : public IControl;

Convert the common control stuff into a template, and give it the type of control I want to derive from.

However I’m not sure this will work, because the template templatizes Edit, but it doesn’t necessarily create one does it? When I create the template will I actually be able to create the Edit?

And secondly, if this is possible, is it possible in C#? What would it look like?

  • 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-23T14:38:04+00:00Added an answer on May 23, 2026 at 2:38 pm

    I can’t say I quite followed your question, but in regards to:

    However I’m not sure this will work,
    because the template templatizes Edit,
    but it doesn’t necessarily create one
    does it? When I create the template
    will I actually be able to create the
    Edit?

    I would go for

    template<class Controlled_t>
    class MyControl : public Controlled_t, public IControl
    {
     //My Control inherits from its templated class
    }
    

    so that
    MyControl<Edit> inherits Edit (which is created) and the interface

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

Sidebar

Related Questions

Lets say all I have is a bunch of timestamps that represent the time
Let's say I have one class Foo that has a bunch of logic in
First of all, I want to say that I know there are a bunch
Say you have a bunch of files. Say you can store meta data to
Dumb question. Lets say I have a bunch of person objects with their fields
Say I have a class Code defined like this, with a user specified type
I have a core data object that has a bunch of optional values. I'm
What I think I need to do is create some code that lets me
I have some asp.net code that populates the fields in a LINQ to SQL
I have a bunch of old VB.NET code, written originally on VS2005, and now

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.