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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:41:27+00:00 2026-05-13T10:41:27+00:00

the title probably is misleading, but i didn’t really know how to name it.

  • 0

the title probably is misleading, but i didn’t really know how to name it.

let’s say I have the following structs

template <typename T>
struct SillyBase{
   void doFunnyStuff(vector<T> vec){
        dummyField = T();
        for(int i=0; i<10; i++)
            vec.push_back(dummyField++);
    }
    T dummyField;
 };

struct A : public SillyBase<char>{};

struct B : public SillyBase<float>{};

now let’s further assume i have a pointer

ISillyBase* ptr;

which is pointing to an object of a DECENDANT class (A or B) of SillyBase – however, i DON’T KNOW which one (i just know it’s either A or B);

Is there ANY way for me to call doFunnyStuff() ?

maybe something like:

vector<dynamic_generic_type_of(ptr)> vec;
ptr->doFunnyStuff(vec);

thanks!

  • 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-13T10:41:28+00:00Added an answer on May 13, 2026 at 10:41 am

    In your example you can’t have SillyBase* because SillyBase is defined as

    template <typename T> struct SillyBase {...}
    

    So you need to provide type …

    Another problem is that you pass a copy of vector<T> into doFunnyStuff() which you then populate … that does not seems right because when the method returns you lose your vec, was it supposed to be reference vector<T>& ?

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

Sidebar

Related Questions

Alright, probably not the best title, but meh. I have the following code inside
The title is probably confusing but I didn't know how else to paraphrase it.
Probably have wrong title,but I don't know how to describe it. int x=0x4a; h=!(0x80000000000&(0x39+(~x+1)));
The title might be worded strange, but it's probably because I don't even know
Sorry if the title is misleading, but I really couldn't think of anything better.
The title is probably not very clear. I have the following example in mind:
Probably not the best title, but I'll explain: I have an array of objects
Sorry, that title probably doesn't make much sense, but what I want to know
I know the title is probably really hard to understand, it was hard to
The question title is probably a bit misleading, but I can't think of a

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.