嗨,我是很新的编码但我有一个相当复杂的pshysics问题CPP解决,我已经遇到了一些问题使用函数作为另一个函数的输入
#include <stdio.h>
#include <cmath>
#include <iostream>
using namespace std;
double delta_x(double x, double n)
{
return x/n;
}
double theta(delta_x(double x,double n),double i, double a)
{
return atan(abs(2*a*((delta_x(x,n)*i)-50)-(0.01)));
}
Codeblox Givex的我以下错误:
|9|error: expected primary-expression before 'double'|
|9|error: expected primary-expression before 'double'|
|9|error: expected primary-expression before 'double'|
|9|error: expected primary-expression before 'double'|
|9|error: expression list treated as compound expression in initializer [-fpermissive]|
|10|error: expected ',' or ';' before '{' token|
|20|error: 'theta' cannot be used as a function|
在此先感谢
您不必再次传递'delta_x'。只需简单地说:'双重theta(双我,双a)'。它应该工作。 – iammilind
在尝试解决复杂问题之前阅读一本好书“C++ Primer 5th edition” - 使用函数是您应该知道的基础知识的一部分 –
我不会这样做,但它是我的phsycics练习的一部分,我需要为星期四sooo我不认为我有足够的时间在这一点上读取任何东西 – TheRlee