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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:34:54+00:00 2026-06-07T17:34:54+00:00

This error: error C2664: ‘Set::Set(int (__cdecl *)(ElemType,ElemType))’ : cannot convert parameter 1 from ‘int

  • 0

This error:

error C2664: ‘Set::Set(int (__cdecl *)(ElemType,ElemType))’
: cannot convert parameter 1 from ‘int (__cdecl
*)(CorrectionT &,CorrectionT &)’ to ‘int (__cdecl *)(ElemType,ElemType)’

is the result of implementing this comparison function as part of a BST based SET class,

int compareCorr(struct CorrectionT &a, struct CorrectionT &b)
{
    if (a.editDistance < b.editDistance) return -1;
    else if (a.editDistance == b.editDistance) return 0;
    else return 1;
}

Class Set

Set(int (*cmpFn)(ElemType, ElemType) = OperatorCmp);

and the use of the comparison function in Set is for add

template <typename ElemType>
void Set<ElemType>::add(ElemType element) {
    bst.add(element);
}

And add in the bst class
restating header file

BST(int (*cmpFn)(ElemType one, ElemType two) = OperatorCmp);

and the function add

template <typename ElemType>
bool BST<ElemType>::add(ElemType data) {
        bool createdNewNode = false;
        recAddNode(root, data, createdNewNode);
        if (createdNewNode) timestamp++;
        return createdNewNode;
}

template <typename ElemType>
bool BST<ElemType>::recAddNode(nodeT * & t, ElemType & data,
                               bool & createdNewNode) {
        if (t == NULL) {
                t = new nodeT;
                t->data = data;
                t->bf = BST_IN_BALANCE;
                t->left = t->right = NULL;
                createdNewNode = true;
                numNodes++;
                return true;
        }
        int sign = cmpFn(data, t->data);
        if (sign == 0) {
                t->data = data;
                createdNewNode = false;
                return false;
        }
        int bfDelta = 0;
        if (sign < 0) {
                if (recAddNode(t->left, data, createdNewNode)) {
                        bfDelta = -1;   /* left subtree is higher */
                }
        } else {
                if (recAddNode(t->right, data, createdNewNode)) {
                        bfDelta = +1;   /* right subtree is higher */
                }
        }
        updateBF(t, bfDelta);
        return (bfDelta != 0 && t->bf != BST_IN_BALANCE);
}

Any idea what is going on here – what is the problem with the comparison function?

  • 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-07T17:34:56+00:00Added an answer on June 7, 2026 at 5:34 pm

    The type of compareCorr is int(Lexicon::CorrectionT&, Lexicon::CorrectionT &). Its parameters are references.

    The type of cmpFn, the parameter of the constructor, is int(*)(ElemType, ElemType). Its parameters are objects (not references).

    The types must match. Assuming that ElemType is Lexicon::CorrectionT, you must either change the function pointer type to have reference parameter types or change the comparer type to have object paramter types. (If you go the reference route, they should both probably use const references, since a comparer should not mutate objects.)

    Alternatively, you can do what the STL does, and make the comparer a part of the type, allowing usage of arbitrary function objects for comparison. Then, the comparer just needs to have parameters of types compatible with the types of the objects being compared (i.e., things don’t need to match exactly).

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

Sidebar

Related Questions

ostream &stream; stream.write(SomeUnsignedCharStar, intSize); error C2664 cannot convert parameter 1 from const unsigned char
visual studio tells me error C2664: 'boost::asio::mutable_buffer::mutable_buffer(const boost::asio::mutable_buffer&)': impossible to convert parameter 1 from
error C2664: 'strcpy' : cannot convert parameter 1 from 'TCHAR *' to 'char *'
This code gives me this error:Cannot implicitly convert type ArrayList[] to ArrayList[][] at this
This error come in log. from='kutbi1@360degree/Smack' to='akash@360degree/Smack' type='error' id='hK1L6-5'> <si xmlns='http://jabber.org/protocol/si' id='jsi_191216212994140179' mime-type='image/png' profile='http://jabber.org/protocol/si/profile/file-transfer'>
Getting this error with jquery & jquery.form. Site has been live for awhile..upgraded to
How do I fix this error? error C2668: 'std::_Tree<_Traits>::end' : ambiguous call to overloaded
Why is this not compiling? error C2660: 'Concrete::WriteLine' : function does not take 1
This error is driving me crazy . I tried freenode #emberjs before asking here.
This error is driving me crazy. I'm developing an App Engine Python application. These

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.