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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:44:16+00:00 2026-06-07T00:44:16+00:00

I want to eliminate the process consumed by a decision using pointers to member

  • 0

I want to eliminate the process consumed by a decision using pointers to member functions. I need to give user options to turn on or off domain checking for a function defined on a limited continues domain.

It’s ok to have pointers to member functions when not using templates. But here I have to generalize my implementation.

Specifically I have three member functions in my class:

1.value is a member function returns value calculated by the member that function points to. The function is a function pointer wich points to either checkedValue or uncheckedValue.
2.checkedValue is a member function that calculates and returns the result, if input is in specified range. else throws a std::domain error.
3.uncheckedValue calculates and returns the result, regardless of domain.

template <typename T>
class IO
{
private:
    typedef T (IO<T>::*functionPtr)(const std::string& name, const T& input) const;
    functionPtr function;
    bool domainValidation;
    void setDomainValidation(const bool& value);
    //...
public:
    // ...
    T value(const std::string& name, const T& input) const;
    T uncheckedValue(const std::string& name, const T& input) const;
    T checkedValue(const size_t& index, const T &input) const;
};

// Implementation:

template <typename T>
void IO<T>::setDomainValidation(const bool &value)
{
    domainValidation = value;
    if(domainValidation)
    {
        // function points to checkedValue()
        function =  & IO<T>::checkedValue; // Here I got undefinded reference error
    }
    else
    {
        // function points to uncheckedValue()
    }
}

template <typename T>
T IO<T>::value(const string &name, const T &input) const
{
    return (this->*function)(name,input);
}

template <typename T>
T IO<T>::uncheckedValue(const string &name, const T &input) const
{
    // simply calculate and return the result
}

template <typename T>
T IO<T>::checkedValue(const string &name, const T &input) const
{
    // if input is in domain, calculate and return the result
    // else throw a std::domain error
}
  • 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-07T00:44:19+00:00Added an answer on June 7, 2026 at 12:44 am

    Your function has signature

    T checkedValue(const size_t& index, const T &input) const;
    

    but not

    T IO<T>::checkedValue(const string &name, const T &input) const;
    

    Note the difference between the types of the first parameter.

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

Sidebar

Related Questions

I want to eliminate empty elements within my String array. This is what I
I want to test my logic at Desktop (to eliminate pain of waiting until
want to open pdf file when a user clicks on hyperlink shown in gridview
want to know why String behaves like value type while using ==. String s1
I want to eliminate blank spaces after '$'. E.g: $ 1000 > $1000 I'm
I want to eliminate B if i scan Serial number bar code: 21524116476CA2006765B Output:
I want to eliminate the GOTO instruction (because as you know is supported only
I want to eliminate = sign for a particular reason. It might looks like
I want to parse this (adv) much (thanks) I want to eliminate the words
i have data that i fetch from an email server i want to eliminate

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.