【发布时间】:2016-11-14 11:44:54
【问题描述】:
您好,我是编码新手,但我有一个非常复杂的心理问题需要用 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 给我以下错误:
|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。简单地说:double theta(double i, double a)。它应该可以工作。 -
在尝试解决复杂问题之前,请阅读一本好书,例如“C++ Primer 5th edition”——使用函数是您应该了解的基础知识的一部分
-
我不会这样做,但这是我周四需要做的物理练习的一部分,所以我认为我当时没有足够的时间阅读任何东西