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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:18:47+00:00 2026-05-25T20:18:47+00:00

It seems to be stupid question but I have never seen something like this!

  • 0

It seems to be stupid question but I have never seen something like this!

int operator() (const std::string& s1, const std::string& s2) const

to me operator is a const member function that return an intger and no variable argument!
but need two const variables s1 and s2?!?! I can’t get the point of this!

class str_dist_ : 
public std::binary_function<std::string, std::string, int> {
public:
  int op() (const std::string& s1, const std::string& s2) const
  {
    if (s1 == s2)
      return 0;
    else if (s1.empty())
      return std::max(s2.size()/2, 1u);
    else if (s2.empty())
      return std::max(s1.size()/2, 1u);
    else 
      return min_edit_distance(s1, s2, zero_one_cost<char>(' '));
  }
  std::string empty() const { return std::string(); }
};
  • 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-25T20:18:47+00:00Added an answer on May 25, 2026 at 8:18 pm

    The operator() part says that objects of type str_dist_ can be “called”, as though it were a function. The (const std::string& s1, const std::string& s2) tells us what the argument actually are.

    For example, say we have an object str_dist_ obj;, and two std::string objects, str1 and str2. Then we can write something like this

    int result = obj(str1, str2);
    

    Under the covers, the previous line is identical to

    int result = obj.operator()(str1, str2);
    

    Notice that the first set of parenthesis are part of the name of the member function operator(), while the second set actually lists the arguments.

    If you want more information, look up Functors or Function Objects. These are the terms used to refer to things such as str_dist_ objects, which have the operator() defined for them. If you google either of those terms, you’re sure to find a lot of information.

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

Sidebar

Related Questions

Sorry if this seems like a stupid question but can't find any info on
This seems like a stupid question, but the closest answer I could find in
This may seem like a stupid question, but what message do i send to
This might seem like a stupid question I admit. But I'm in a small
Ok, this may seem like a stupid question (for Flash Developers) but I really
I feel like this is a stupid question because it seems like common sense
Okay, it seems to be a stupid question, since we have this However, up
I'm really sorry. This must seem like an incredibly stupid question, but unless I
I know this kinda seems like a stupid question and with more research i
This probably sounds like a stupid question, but I'm going to give it 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.