C++ cpp摆锤图形程序编译错误

C++ cpp摆锤图形程序编译错误,c++,dev-c++,bgi,C++,Dev C++,Bgi,在尝试使用DevC++编译一个简单的图形程序时,我遇到以下错误: 不幸的是,y1的名称被采用,因此不能将其用作全局变量 换个名字吧 也似乎你没有使用C++特性,所以你应该删除包含< ,并编译你的源代码作为C来消除关于“代码> char */COD>的警告。第一个问题是:如果修复了这个问题,你仍然有问题,请回来。没有理由使这些变量是全局的。 #include<math.h> #include<process.h> #include<dos.h> #include

在尝试使用DevC++编译一个简单的图形程序时,我遇到以下错误:


不幸的是,
y1
的名称被采用,因此不能将其用作全局变量

换个名字吧


也似乎你没有使用C++特性,所以你应该删除<代码>包含< <代码>,并编译你的源代码作为C来消除关于“代码> char */COD>的警告。

第一个问题是:如果修复了这个问题,你仍然有问题,请回来。没有理由使这些变量是全局的。
#include<math.h>
#include<process.h>
#include<dos.h>
#include<iostream>
#include<conio.h>
#include<graphics.h>
int x1=300,y1=180,x,y;
void display(double i)
{
    circle(300,130,50);
    line(210,60,210,320);
    line(210,60,390,60);
    line(390,60,390,320);
    line(210,320,390,320);
    outtextxy(295,88,"12");
    outtextxy(260,130,"9");
    outtextxy(340,130,"3");
    outtextxy(295,168,"6");
    line(300,130,300,98);
    line(300,98,297,101);
    line(300,98,303,101);
    line(337,130,300,130);
    line(337,130,334,127);
    line(337,130,334,133);
    x=x1+95*cos(i);
    y=y1+95*sin(i);
    line(x1,y1,x,y);
    circle(x,y,10);
    delay(30);
    clearviewport();
}

int main()
{
    int gd=DETECT,gm;
    double i;
    initgraph(&gd,&gm,"C:\\Tc\\BGI");
    while(!kbhit())
    {
        for(i=2;i>1;i=i-0.01)
            display(i);
        for(i=1;i<2;i=i+0.01)
            display(i);
    }
    getch();
    return 0;
    }
7   12  \C++ Code\Test.cpp  [Error] 'int y1' redeclared as different kind of symbol
1   0   \C++ Code\Test.cpp  In file included from Test.cpp
266 24  \Dev-Cpp\MinGW64\x86_64-w64-mingw32\include\math.h  [Note] previous declaration 'double y1(double)'
        \C++ Code\Test.cpp  In function 'void display(double)':
15  23  \C++ Code\Test.cpp  [Warning] deprecated conversion from string constant to 'char*' [-Wwrite-strings]
16  23  \C++ Code\Test.cpp  [Warning] deprecated conversion from string constant to 'char*' [-Wwrite-strings]
17  23  \C++ Code\Test.cpp  [Warning] deprecated conversion from string constant to 'char*' [-Wwrite-strings]
18  23  \C++ Code\Test.cpp  [Warning] deprecated conversion from string constant to 'char*' [-Wwrite-strings]
26  15  \C++ Code\Test.cpp  [Error] invalid operands of types 'double(double)' and 'double' to binary 'operator+'
27  16  \C++ Code\Test.cpp  [Error] invalid conversion from 'double (*)(double)' to 'int' [-fpermissive]
6   0   \C++ Code\Test.cpp  In file included from Test.cpp
212 6   \Dev-Cpp\MinGW64\x86_64-w64-mingw32\include\graphics.h  [Note] initializing argument 2 of 'void line(int, int, int, int)'
        \C++ Code\Test.cpp  In function 'int main()':
37  33  \C++ Code\Test.cpp  [Warning] deprecated conversion from string constant to 'char*' [-Wwrite-strings]
28      \C++ Code\Makefile.win  recipe for target 'Test.o' failed