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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:11:47+00:00 2026-05-27T15:11:47+00:00

In javascript it’s possible to do things like this: SomeObject.somefunction(function(someparameters){ //do some things. });

  • 0

In javascript it’s possible to do things like this:

SomeObject.somefunction(function(someparameters){
//do some things.
});

like in jquery each function:

$('.rawdata').each(function(index){
$(this).attr('some',index);
});

I searched and saw that in c/c++ we can use functions as parameters using function pointers, but didn’t found a way to do some thing like the above one: to declare the function that will be pointed in the moment that it will be used. So is this possible? If it isn’t, what would you recommend to use instead?

  • 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-27T15:11:48+00:00Added an answer on May 27, 2026 at 3:11 pm

    Check out lambda functions, added to C++ in the latest standard (C++11).

    std::vector<int> vec;
    // ...
    // Double each element in the vector
    std::transform(vec.begin(), vec.end(), [] (int elem) { return 2*elem; });
    

    The parameter that will receive the function will have to be either a template (whose precise type will be automatically deducted from the lambda function itself), either std::function<> (a type-erasure class designed to hold any type of “callable thing” with the given prototype).

    By the way, function pointers aren’t the only way to pass a function-like object to a procedure in C++ even before the C++11 standard: any object that overloads operator() (i.e. the function call operator) can be called as a function, and is said to be a “functor”. Functors are quite ubiquitous when programming with the STL1 algorithms.


    1. @nitpickers: I know and I don’t care, we all know what I’m talking about.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Javascript functions can be declared on a objects prototype like this: <object name>.prototype.<variable name>=function(){
Javascript: var images = $('#slideshow').children(); var dot_holder = $('#slider_dots'); /* Create the dots*/ images.each(function(index,item){
JavaScript (jQuery) function display_youtube(new_url) { $('#movie_url').removeAttr('value'); $('#embed_url').removeAttr('src'); $(document).ready(function() { $('#movie_url').attr('value', new_url); $('#embed_url').attr('src', new_url); $('#shade').css('display',
Javascript is an incredible language and libraries like jQuery make it almost too easy
JavaScript is purported to have first-class functions, so this seems like the following ought
JavaScript (JQuery) $('input').keyup(function(e) { var code = e.keyCode ? e.keyCode : e.which; switch(code) {
JavaScript post request like a form submit shows you how to submit a form
JavaScript does funky automatic conversions with objects: var o = {toString: function() {return 40;
Javascript run at page opening or later by user action like clicking a button
javascript code: $.getJSON(comprueba_login.php, {usuario:$(#usuario).val(), pwd:$(#contrasena).val()}, function(data){ alert(resultado: + data.resultado); }); php code: <?php include

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.