未定义的符号c ++问题 [英] undefined symbol c++ problem
本文介绍了未定义的符号c ++问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好
i dono为什么turbo C会报告此错误。
http: //upcity.ir/images2/15114259861070390340.png [ ^ ]
#include < graphics.h >
#include < dos.h >
#include < conio.h >
void Drawcar(){
setcolor( 15 );
行(spX [ 1 ],spY [ 1 ],spX [ 2 ],spY [ 2 ]);
行(spX [ 2 ],spY [ 2 ],spX [ 3 ],spY [ 3 ]);
行(spX [ 3 ],spY [ 3 ],spX [ 4 ],spY [ 4 ]);
行(spX [ 4 ],spY [ 4 ],spX [ 4 ],spY [ 4 ]);
行(spX [ 1 ],spY [ 1 ],spX [ 4 ],spY [ 4 ]);
pieslice( 100 , 400 , 40 , 10 , 25 );
arc(spX [ 0 ],spY [ 0 ] = 75 ;, 90 , 190 , 30 跨度>);
circle( 100 , 400 , 25 < /跨度>);
}
void move_sp( int a){
for ( int i = 0 ; i< = 20 ; i ++){
spX [i] + = a;
spY [i] + = a;
Drawcar();
}
}
int main(){
int g = DETECT,m;
initgraph(& g,& m, c:\\turboc3 \\ BGI跨度>);
public int spX [ 20 ] = { 0 };
public int spY [ 20 ] = { 0 };
spX [ 0 ] = 75 ;
spY [ 0 ] = 375 ;
spX [ 1 ] = 75 ;
spY [ 1 ] = 345 ;
spX [ 2 ] = 125 ;
spY [ 2 ] = 300 ;
spX [ 3 ] = 225 ;
spY [ 3 ] = 330 ;
spX [ 4 ] = 275 ;
spY [ 4 ] = 345 ;
spX [ 5 ] = 300 ;
spY [ 5 ] = 350 ;
move_sp( 1 );
getch();
closegraph();
return 0 ;
}
什么是
解决方案
因为DrawCar不是Main函数的一部分!它也不是......
将公共变量移出主方法并进入类的主体。
我不知道为什么Turbo C不会抱怨用户使用public关键字,但这可能是因为它是一个非常古老的编译器...
hello
i dono why turbo C reports this error.
http://upcity.ir/images2/15114259861070390340.png[^]
#include<graphics.h>
#include<dos.h>
#include<conio.h>
void Drawcar(){
setcolor(15);
line(spX[1],spY[1],spX[2],spY[2]);
line(spX[2],spY[2],spX[3],spY[3]);
line(spX[3],spY[3],spX[4],spY[4]);
line(spX[4],spY[4],spX[4],spY[4]);
line(spX[1],spY[1],spX[4],spY[4]);
pieslice(100,400,40,10,25);
arc(spX[0],spY[0]=75;,90,190,30);
circle(100,400,25);
}
void move_sp(int a){
for(int i=0;i<=20;i++){
spX[i]+=a;
spY[i]+=a;
Drawcar();
}
}
int main(){
int g=DETECT,m;
initgraph(&g,&m,"c:\\turboc3\\bgi");
public int spX[20]={0};
public int spY[20]={0};
spX[0]=75;
spY[0]=375;
spX[1]=75;
spY[1]=345;
spX[2]=125;
spY[2]=300;
spX[3]=225;
spY[3]=330;
spX[4]=275;
spY[4]=345;
spX[5]=300;
spY[5]=350;
move_sp(1);
getch();
closegraph();
return 0;
}
what''s
解决方案
Because DrawCar is not a part of the Main function! Nor can it be...
Move your public variables out of the main method and into the main body of the class.
I have no idea why Turbo C isn''t complaining about the user of the "public" keyword on them, but it''s probably because it''s a very old compiler...
这篇关于未定义的符号c ++问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文