c++ - Conversion from ‘callback<void>::func*’ to non-scalar type ‘callback<void>’ requested error when using g++ 4.8.3? -
To understand the templates and function objects of C ++, I want to create a template class callback, which is a type that is approximate approximation of curry action. The purpose of the type is
callback & lt; R, b1>
has a member R operator () (B1)
, thus the callback function objects, which specify the return of the first template type, the function and the remaining arguments which pass the function To specify the type of arguments to do. By using this method but when I used the following code to create an example and compile it, I found an error: template
I found an error when compiling:
forstack.cc6: 65: error: conversion from 'callback'; Zero & gt; :: func * for 'non-scalable type callback & lt; Zero & gt; The requested callback & lt; Zero & gt; Cb0 = Callback & lt; Zero & gt; :: init (printmsg, "dillon \ n");
What knowledge do I need for this problem? Thanks!
EDIT: According to the answer from @Dennis-B and @TheOne, I can add two statements:
typedef struct func * fptr; Private: Temporary fptr fn; Public: Callback (FTPPL FN): FN (FN) {Stud :: COAT & LT; & Lt; "1111 \ n";}
But I do not know the mechanism of C ++ or what rule C ++ to call this constructor function or do not know :
callback (FPTR FN): Fn {std :: cout & lt; & Lt; "1111 \ n";}
The type of a brain teaser.
My guess is that callback & lt; Void & gt;
does not have a constructor which is callback & lt; Void & gt; :: func *
accepts.
You can type cb0
to callback & lt; Void & gt; :: Func *
or add the constructor to callback
, which will be callback