Error:Function as a parameter for constructor !

Z

zqiang320

I have a structure which constructor have a Function pointor as
paramter, But I can't compile it, Could somebody help me check it, I
have post a topic earlier, and Alf P. Steinbach have give me some
advice, I post a simple code here, Could somebody help me check it ?
Thank you very much!

void figauss(const int x, int &a, int &y, int &dyda){

};

struct Fitmrq {

void (*funcs)(const int, int &, int &, int &);

Fitmrq(int &xx, int &yy, int &ssig, int &aa,
void funks(const int,int &, int &, int &), const double
TOL=1.e-3) {

}

};



int main()
{

int xx;
int yy;
int ssigg;
int a;
void fgauss(const int, int , int , int );
Fitmrq mrq(xx,yy,ssigg,a,fgauss,0.000001);

return 1;
}
 
A

Alf P. Steinbach

* zqiang320:
I have a structure which constructor have a Function pointor as
paramter, But I can't compile it, Could somebody help me check it, I
have post a topic earlier, and Alf P. Steinbach have give me some
advice, I post a simple code here, Could somebody help me check it ?
Thank you very much!

void figauss(const int x, int &a, int &y, int &dyda){

};

struct Fitmrq {

void (*funcs)(const int, int &, int &, int &);

Fitmrq(int &xx, int &yy, int &ssig, int &aa,
void funks(const int,int &, int &, int &), const double
TOL=1.e-3) {

}

};



int main()
{

int xx;
int yy;
int ssigg;
int a;
void fgauss(const int, int , int , int );
Fitmrq mrq(xx,yy,ssigg,a,fgauss,0.000001);

return 1;
}

Try removing the declaration of 'fgauss' in 'main', and change 'fgauss' to
'figauss' in the declaration of 'mrq'.

Cheers & hth.,

- Alf

PS: By the way, it's a good idea to also post the exact error message plus info
about which compiler and version. The FAQ has some info about how to post
questions about Code That Does Not Work.
 
T

Tonni Tielens

        Fitmrq(int &xx, int &yy, int &ssig, int &aa,
        void funks(const int,int &, int &, int &), const double
        TOL=1.e-3) {
void fgauss(const int, int , int , int );

fgauss is of type
void (const int, int, int, int)

while your constructor expects a function pointer of type:
void (const int, int&, int&, int&);
 
Q

Qiang Zhong

* zqiang320:











Try removing the declaration of 'fgauss' in 'main', and change 'fgauss' to
'figauss' in the declaration of 'mrq'.

Cheers & hth.,

- Alf

PS: By the way, it's a good idea to also post the exact error message plus info
about which compiler and version. The FAQ has some info about how to post
questions about Code That Does Not Work.

--
Due to hosting requirements I need visits to <url:http://alfps.izfree.com/>.
No ads, and there is some C++ stuff! :) Just going there is good. Linking
to it is even better! Thanks in advance!- Òþ²Ø±»ÒýÓÃÎÄ×Ö -

- ÏÔʾÒýÓõÄÎÄ×Ö -

Thank you very much!
I have change the line:
void fgauss(const Doub x, VecDoub_I &a, Doub &y, VecDoub_O &dyda);
Fitmrq mrq(xx,yy,ssigg,a,fgauss,0.000001);

//Then I got correct result!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top