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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:07:14+00:00 2026-05-27T02:07:14+00:00

I could’ve sworn this worked some time ago when my object was declared on

  • 0

I could’ve sworn this worked some time ago when my object was declared on the heap instead of on the stack. I have a function that takes a pointer to a base class ( detail::DuplicateFn ). – Though as that is a virtual class the actual pointers are given by a derived class (ie dteail::SkipFn)

1>GMProject.cpp(298): error C2664:
'void xml_tree<V>::combine_if<bool(__cdecl *)(const T &,const T &)>(const xml_tree<V> &,Predicate,const detail::DuplicateFn *)' :
cannot convert parameter 3 from 'detail::SkipFn (__cdecl *)(void)' to 'const detail::DuplicateFn *'

My function:

void GMProject::CombineTree(const pTree& Other) {
    detail::SkipFn foo();
        ProjectTree.combine_if(Other, &SimilarTreeValue<GMProject::pTree>, &foo);
}

Where ProjectTree.combine_if() as third parameter requires a pointer to “DuplicateFn” – and SkipFn is derived from DuplicateFn.

As said this works (like I expect) correctly if I declare “foo” on the heap. However it doesn’t when declaring foo on the stack (or -ultimatelly- making foo a temporary). Why is that?

  • 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-27T02:07:15+00:00Added an answer on May 27, 2026 at 2:07 am
    detail::SkipFn foo();
    

    foo is not an object. It’s a function whose return type is detail::SkipFn. So, instead try –

    detail::SkipFn foo;   // Notice the removal of (). Google most vexing parse 
                          // for explanation.
    

    Is there any difference between List x; and List x();?

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

Sidebar

Related Questions

Could somebody please name a few. I could given time, but this is for
could you tell me what does this declaration mean. Why does it have ul
Could you please help me optimize this query. I've spent lots of time and
Could someone give me some advice why I have a memory leak associated to
I have some data like this: 1 2 3 4 5 9 2 6
Could someone please explain when would I want to use delegation instead of inheritance?
I have just tried to save a simple *.rtf file with some websites and
Could someone help me to convert this rule for nginx? RewriteRule ^([^/]*)/([^/]*)/?$ index.php?a=$1&b=$2 [L,NC]
Could some one direct me to a command or a way on Linux to
Could you help me plaese! I had to use next jQuery functionality. elem.parents('.CanvasRoot:first').unbind('click').click(function(){ ...

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.