C++ 使用G+编译时,会出现以下错误:+;

C++ 使用G+编译时,会出现以下错误:+;,c++,compiler-construction,C++,Compiler Construction,我对编程有点陌生,你可以从我之前的问题中看出这一点。我想知道是否有人能帮我解决最近遇到的这个问题。我试图使用g++编译脚本main.cpp,但出现以下错误: Donny@Donny-PC /cygdrive/c/Users/Donny/Desktop/equation/equations/equations $ g++ main.cpp -o don.exe main.cpp:3:11: error: ‘::main’ must return ‘int’ void main(){

我对编程有点陌生,你可以从我之前的问题中看出这一点。我想知道是否有人能帮我解决最近遇到的这个问题。我试图使用g++编译脚本main.cpp,但出现以下错误:

Donny@Donny-PC /cygdrive/c/Users/Donny/Desktop/equation/equations/equations
$ g++ main.cpp -o don.exe
main.cpp:3:11: error: ‘::main’ must return ‘int’
 void main(){
       ^
main.cpp: In function ‘int main()’:
main.cpp:36:22: error: ‘pow’ was not declared in this scope
  float n=pow(10.0,9.0);
                  ^
main.cpp:43:27: error: ‘sin’ was not declared in this scope
  float R56=(lb1/sin(theta1)) * ((tan(theta1))-theta1) + (lb2/sin(theta1)) *                ((tan(theta1))-theta1) +
                       ^
main.cpp:43:44: error: ‘tan’ was not declared in this scope
  float R56=(lb1/sin(theta1)) * ((tan(theta1))-theta1) + (lb2/sin(theta1)) *     ((tan(theta1))-theta1) +
                                        ^
main.cpp:48:40: error: ‘cos’ was not declared in this scope
  d*((pow(tan(theta1),2))/cos(theta1)) +
                                    ^
<> P>奇怪的是,这个代码是在微软Visual Studio 2010 C++编译时工作的。任何帮助都将不胜感激

编辑:

所以,修正了上面显示的许多错误,但是我仍然有一点困难来修正void主错误。下面是我的代码的外观:

#include<iostream>
#include<cmath>
using namespace std;
void main(){
    float r, i, f, beta, alpha;
    cout<<"Enter value of R : ";............
#包括
#包括
使用名称空间std;
void main(){
浮动r,i,f,β,α;

cout第一个错误应该是不言自明的。标准规定
main
函数必须返回
int
,但您已将其声明为
void
。从
main
函数返回
0
以表示正常终止。Microsoft编译器在这一点上没有那么严格


使用
#include

可以纠正所有剩余的错误。第一个错误很容易处理;将
main
的定义更改为
int
,并在成功完成后返回
0
。其他错误可能是由于您忽略了
(这是我相信这些函数被定义的地方)。奇怪的是,它是用微软Visual Studio 2010 C++编译的。我怀疑。这两个编译器没有什么不同,允许一个主方法具有一个空签名。@ NWD,它是微软支持的非标准扩展。只要你的<代码> main()不试图返回任何微软C++编译器允许的东西。尤克,伊克斯。我想,你知道的越多。谢谢。但是由于代码是C++,包含< /Cord>标题更适合。你不必明确地从代码< >代码> >代码>返回EXITION <代码> >从你的代码>主< /代码>函数。嗨,这就是我为所做的编辑,但我需要帮助理解如何处理void main:#include#include使用名称空间std;void main(){float r,I,f,beta,alpha;cout@user1886681请不要叫它“void main”,这是一个int main。