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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:17:52+00:00 2026-05-11T20:17:52+00:00

I am working on making an expression class: template<typename T, typename U> class expression

  • 0

I am working on making an expression class:

template<typename T, typename U>
class expression
{
public:
    expression(T vala, U valb, oper o){val1 = vala; val2 = valb; op = o;}
    operator bool{return(val1 op val2);}
private:
    T val1;
    U val2;
    oper op;
};

as you can see, this is somewhat pseudocode, because I need an operator class. My original thought was to create an array of all possible operators, and then convert it through a string, but that wouldn’t work because of the sheer number of operators, and how to convert it to a string except through a two dimensional array, where n[0][0] has the first operator, and n[0][1] has that operators string.

Does anybody have any suggestions to adding an operator value to my expression class?

  • 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-11T20:17:52+00:00Added an answer on May 11, 2026 at 8:17 pm

    Maybe a function pointer. Instead of …

    operator bool{return(val1 op val2);}
    

    … code it as …

    operator bool{return op(val1, val2);}
    

    … in which case op can be a pointer to a (any) function which takes two parameters and which returns bool.

    template<typename T, typename U>
    class expression
    {
    public:
        //define pointer-to-function type
        typedef bool *oper(const T& val1, const U& val2);
        ... etc ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on making a simple server application with python, and I'm trying to
At my current job I've been working on making web apps with Java, Tapestry,
Hi im making a custom Textbox i got everty thing working but how do
I'm working on a web page where I'm making an AJAX call that returns
I'm working with some example java code for making md5 hashes. One part converts
I am making a regex expression in which I only want to match wrong
I've got a working regular expression, but I'd like to make it a tad
I am working on making a custom section of my app.config and web.config to
I'm working on making a special UIScrollView to show a timeline of events, (Like
I'm working on making my first Python C extension, which defines a few functions

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.