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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:16:33+00:00 2026-05-28T03:16:33+00:00

I have a little bit philosophical question. There is a class A class A

  • 0

I have a little bit “philosophical” question. There is a class A

class A
{

}

and classes A1, A2, A3 derived from A.

class A1 : public A
{
}

class A2 : public A
{
}

class A3 : public A
{
}

and one static method processing objects A – A3. Which variant should be preferred?

A)
class Algorithms  
{
  //Object of derived class could be use instead of the object base class
  public: void test (const A *a) {}
};

or

B)
class Algorithms
{
  public: 
  //Templatize parameter
  template <typename TType>
  void (const TType *a) {}
};

In my opinion, in this case, the option a) is preferable (so the templatization is redundant…)

The option b) means that the input can be any type, that is not in any inheritance relationship to the class A.

It would be used in the case where the method test() can work with another type B

class B
{
}

and types A-A3.

Are these conclusions correct or not?

  • 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-28T03:16:33+00:00Added an answer on May 28, 2026 at 3:16 am

    The template allows you do to the same things with unrelated classes.

    You can also use adapters so you would make adapters for A and for B (unrelated) that derive from a common adapter and perform the functionality you want.

    The main purpose of a template normally is to apply the same logic to primarily unrelated types because, for example, you are manipulating collections of types in some way and the algorithm relates to how you manipulate them.

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

Sidebar

Related Questions

I have this little bit of code: using System; using System.Web.Mvc; public class SecureFilter
I have little bit longer question for you - but hope answer will be
I am new in iphone development and i have little bit Question. My Question
I have a little bit of C programming experience from school, but it was
I have a little bit of experience in c/c++ from college but have not
i have a little bit lame question, but it's time i have this finally
I have a little bit seen the representation of an array in memory with
I have a little bit of Javascript that almost works correctly. Here's the code:
So I have a little bit of a problem. I working on a project
Where I work we have a little bit of a dilemma... I work on

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.