0

尝试分配函数指针时出现左值操作数问题。我不知道问题到底出在哪里,但我会给你所有与该特定问题有关的代码。

    double *func(double); //initialization for a pointer to a function that both returns a double and requires a double

    func = &xsquaredsinx; //trying to make the pointer point at a function that both returns a double and requires a double
    func = &halfcircle;//others that are the same
    func = &testfunction;

任何帮助都会很棒。

4

2 回答 2

3

的声明语法func不正确;该声明声明了一个接受 adouble并返回 a的函数double*。正确的申报方式func是:

double (*func)(double);
于 2012-03-02T02:27:53.783 回答
0

我相信您的声明double *func(double);没有声明指向函数的指针,而只是声明了一个函数。试试吧double (*func)(double);

这是一个很好的教程: http: //www.newty.de/fpt/fpt.html#assign

于 2012-03-02T02:30:11.677 回答