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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:20:43+00:00 2026-05-22T03:20:43+00:00

I get a code for Fibonacci Heap. This code uses the follow function to

  • 0

I get a code for Fibonacci Heap. This code uses the follow function to compare two keys:

int
cmp(void *x, void *y)
{
    int a, b;
    a = (int)x;
    b = (int)y;

    if (a < b)
        return -1;
if (a == b)
        return 0;
    return 1;
}

This works because the KEY is currently a INT number.

I would like to adapt this code to use my class called “Node”. This class have implemented the operator <. >, <=, == and >=.

My adaptation in the code was:

Node a, b   // instead int a, b
a = (Node)x;
b = (Node)y;

But I get the error:

dijkstra.cpp:168: error: no matching function for call to 'Node::Node(void*&)'
graph.h:39: note: candidates are: Node::Node()
graph.h:39: note:                 Node::Node(const Node&)

I tried also:

Node a, b   // instead int a, b
a = (Node*)x;
b = (Node*)y;

and get the error:

dijkstra.cpp:168: error: no match for 'operator=' in 'a = (Node*)x'
graph.h:39: note: candidates are: Node& Node::operator=(const Node&)

I give up to try set the value and solve the question as a follow:

int cmp(void *x, void *y)
{ 
    if ((Node*)x < (Node*)y)
        return -1;
    if ((Node*)x == (Node*)x)
        return 0;
    return 1;
}

I would like to understand what I am doing wrong in the previous examples.

Thanks in advance.

  • 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-22T03:20:44+00:00Added an answer on May 22, 2026 at 3:20 am

    Change the following lines

    a = (Node*)x;
    b = (Node*)y;
    

    to

    a = *( (Node*) x); 
    // type cast from void* to Node* and then fetch the contents by dereferencing the pointer.
    
    b = *( (Node*) y);
    

    You were merely type casting the pointers from void* to Node* and trying to assign the pointer to a variable of type Node.

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

Sidebar

Related Questions

I've been trying to get this code to work for hours! All I need
hI, I'm trying to get this code from Larry Nyhoff's book to compile in
If I get an error code result from a Cocoa function, is there any
Code 1: public static int fibonacci (int n){ if (n == 0 || n
I'm trying to get some code working that a previous developer has written. Yep,
I've spent hours trying to get my code to work, its a rats nest
I'm currently using Rcov to get C0 code coverage analysis for a rails project
Using the following code I get a nice formatted string: Request.QueryString.ToString Gives me something
I'm trying to get the following code working: string url = String.Format(@SOMEURL); string user
I tried the following code to get an alert upon closing a browser window:

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.