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

  • Home
  • SEARCH
  • 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 8140899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:19:09+00:00 2026-06-06T12:19:09+00:00

I put the following into Ideone.com (and codepad.org): #include <iostream> #include <string> #include <tr1/functional>

  • 0

I put the following into Ideone.com (and codepad.org):

#include <iostream>
#include <string>
#include <tr1/functional>
 
struct A {
    A(const std::string& n) : name_(n) {}
    void printit(const std::string& s) 
    {
        std::cout << name_ << " says " << s << std::endl;
    }
private:
    const std::string name_;
};
 
int main()
{
    A a("Joe");
    std::tr1::function<void(const std::string&)> f = std::tr1::bind(&A::printit, &a, _1);
    a("Hi");
}

And got these errors:

prog.cpp: In function ‘int main()’:

prog.cpp:18: error: ‘_1’ was not declared in this scope

prog.cpp:19: error: no match for call to ‘(A)(const char [3])’

prog.cpp:18: warning: unused variable ‘f’

I can’t for the life of me figure out what’s wrong on line 18.

  • 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-06T12:19:10+00:00Added an answer on June 6, 2026 at 12:19 pm

    Two errors:

    1. _1 is defined within the namespace std::tr1::placeholders. You need to either using namespace std::tr1::placeholders; within main(), or use std::tr1::placeholders::_1.

    2. Line 19 should be f("Hi"), not a("Hi").

    #include <iostream>
    #include <string>
    #include <tr1/functional>
    
    struct A {
        A(const std::string& n) : name_(n) {}
        void printit(const std::string& s) 
        {
            std::cout << name_ << " says " << s << std::endl;
        }
    private:
        const std::string name_;
    };
    
    int main()
    {
        using namespace std::tr1::placeholders;  // <-------
    
        A a("Joe");
        std::tr1::function<void(const std::string&)> f = std::tr1::bind(&A::printit, &a, _1);
        f("Hi");    // <---------
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Looking to put the following into my htaccess file: User visits http://mysite.com/test/test/123 User is
I am trying to put the following code into VBA. What I ideally want
The following jQuery example should put some text into the div, but it doesn't.
I tried the following code tree. If I put the header file hello.h into
I was having problems inserting a string into the following tag : <tr id=rowBulkOptions
How would I put the following information into a Python dictionary -- http://userpage.chemie.fu-berlin.de/diverse/doc/ISO_3166.html ?
I'm trying to put the following logic into an Extension method that let's me
How can I put the following into a loop: if ($('#s1').attr('checked') ){ image(s1, mouseX-s1.width/2+random(-brushSize,
I put the following algorithm into the login control event. It is fired after
How to Put the following query result into a List var result = 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.