Visual c++ 错误消息:指向函数的指针

Visual c++ 错误消息:指向函数的指针,visual-c++,Visual C++,我收到一条错误消息,说表达式必须具有(指向-)函数类型。我做错了什么?我刚开始编码,我知道我很烂,哈哈。我不知道如何得到工作距离的公式 #include <cmath> //headerfile #include <iomanip> #include <iostream> enter code here using namespace std; int main() { double d; double t; dou

我收到一条错误消息,说表达式必须具有(指向-)函数类型。我做错了什么?我刚开始编码,我知道我很烂,哈哈。我不知道如何得到工作距离的公式

#include <cmath>    //headerfile
#include <iomanip>
#include <iostream>

    enter code here

using namespace std;

int main()
{
    double d;
    double t;
    double g;
    char choice ='y';



    //output numbers to console


    while (choice == 'y' || choice =='Y')
    {
        cout<<"Please input a value for the time"<< endl<<endl;
        cin>>t;

        g = 32;
        d = (g)(t*t);

        if (t<0)
            cout<<"You cannot have a negative time"<<endl<<endl;

        else


        cout<<setw(8)<<fixed<<setprecision(2)<<"\n""The distance the ball has fallen is "<<d<<" feet"<<endl<<endl;

        cout<<"Would you like to run this again? y for yes, any other key for no."<< endl<<endl;
        cin>>choice;
        cout<<endl;


    }
system ("Pause");
return 0;

}
#包括//头文件
#包括
#包括
在这里输入代码
使用名称空间std;
int main()
{
双d;
双t;
双g;
char choice='y';
//将数字输出到控制台
while(choice='y'| choice='y')
{

cout如果(g)(t*t)应该是一个正常的乘法运算,那么它应该是g*t*t。

在你的代码中,
g
是一个双精度的,但是你使用它就像它是一个指向函数的指针(
d=(g)(t*t);
)。如果你真正想要的是将
t*t
乘以
g
,你就忘了一个
*

d = (g)*(t*t);