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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:22:18+00:00 2026-06-01T12:22:18+00:00

I have a complicated problem, and I need help. I have a base case,

  • 0

I have a complicated problem, and I need help.

I have a base case,

class ParamBase
{
    string paramValue;
    //...
}

and a bunch of class templates with different template parameters.

template <typename T>
class Param : public ParamBase
{
   T value;
   //...
}

Now, each instance of Param has different template parameter, double, int, string… etc.

To make it easier, I have a vector to their base class pointers that contains all the instances that have been created:

vector<ParamBase*> allParamsObjects;

The question is:

How can I run a single function (global or member or anything, your choice), that converts all of those different instances’ strings paramValue with different templates arguments and save the conversion result to the appropriate type in Param::value. This has to be run over all objects that are saved in the vector allParamsObjects.

So if the template argument of the first Param is double, paramValue has to be converted to double and saved in value; and if the second Param’s argument is int, then the paramValue of the second has to be converted to int and saved in value… etc.

Any help would be highly appreciated 🙂

  • 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-01T12:22:20+00:00Added an answer on June 1, 2026 at 12:22 pm

    Something like this?

    class ParamBase {
        std::string paramValue;
    public:
        virtual void convert() = 0;
    };
    
    template <typename T>
    class Param : public ParamBase
    {
        T value;
    public:
        virtual void convert() {
            std::stringstream ss(paramValue);
            ss >> value;
        }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some complicated, problem to be solved. Now I need to write such
I have the following tricky problem: I have implemented a (rather complicated) class which
I have a fairly complicated problem. The usual markup (no problems here): <div class=wrapper>
I have a complicated problem and I hope to explain it clearly possible... I
Im having a very strange problem, i have a complicated view that returns incorrect
I have a problem with (for me to complicated) MySql query. Okay, here is
Alright, this problem is a little complicated, so bear with me. I have a
I have a complicated report that I need to draw with GDI+ (I don't
I have been thinking about a complicated view/query I need to create but I
I have a complicated MySQL query which takes a lot of time, selecting from

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.