Ask Your Question
0

error non-standard syntax; use '&' to create a pointer to membe

asked 2019-01-21 16:30:58 -0600

Allaye gravatar image

updated 2019-01-21 19:38:30 -0600

sjhalayka gravatar image

//

void Blending::Blend(int, void*)
{
    alpha = (double)defaultvalue / 100;
    addWeighted(img, alpha, img2, 1.0 - alpha, 0, des);
    imshow("Blendimage", des);
}

int main()
{
    Blending ble;

    ble.Blend(defaultvalue, 0);

    createTrackbar("Blend", "Blendimage", &defaultvalue, maximumvalue, ble.Blend);
    waitKey(0);

    return 0;
}

i get the non-standard error when i pass the Blend function to createTrackBar using the object of the class to call the function direct.. any help pls

edit retag flag offensive close merge delete

Comments

using the object of the class to call the function direct.

problem is: your code does NOT use the object ;)

berak gravatar imageberak ( 2019-01-21 18:51:36 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
3

answered 2019-01-21 17:56:56 -0600

sjhalayka gravatar image

updated 2019-01-21 17:59:11 -0600

You can make the function static, and call it accordingly:

class c
{
public:
    static void on_trackbar(int, void*)
    {

    }
};

// ...

createTrackbar("Foo", "Bar", &some_variable, another_variable, c::on_trackbar);

If this code does not solve your problem, then please let me know. On the other hand, if this code does solve your problem, then please upvote my answer and mark it as correct. Thank you.

edit flag offensive delete link more

Comments

header file------

class Blending
{
public:
    static void Blend(int, void*);
    int Blended();
    //int imageinput();

    double alpha, beta;
     int  key;
    int defaultvalue;
};


    void Blending::Blend(int, void*)
    {
        Blending b;
        b.alpha = (double)b.defaultvalue / 100; // error uninitialized local variable "b" used 
        addWeighted(img, b.alpha, img2, 1.0 - b.alpha, 0, des);
        imshow("Blendimage", des);
    }


int main()
{
    Blending ble;

    ble.Blend(defaultvalue, 0);

    createTrackbar("Blend", "Blendimage", &defaultvalue, maximumvalue, Blending::.Blend);
    waitKey(0);

    return 0;
}

when i build the code i get the error message "uninitialized local variable "b" used", any help

Allaye gravatar imageAllaye ( 2019-01-22 05:07:12 -0600 )edit

when i build the code i get the error message "uninitialized local variable "b" used", any help

Allaye gravatar imageAllaye ( 2019-01-22 05:07:28 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2019-01-21 16:30:58 -0600

Seen: 796 times

Last updated: Jan 21 '19