Graphics.h 库不起作用
Posted
技术标签:
【中文标题】Graphics.h 库不起作用【英文标题】:Graphics.h library doesn't work 【发布时间】:2016-01-02 16:27:59 【问题描述】:我有一个带有头文件的 C++ 源文件
#include<graphics.h>
Graphics 库好像不在include
文件夹中,我从网上下载了它并将graphics
和winbgim
头文件复制到include
文件夹和libbgi.a
到@ 987654327@文件夹,然而,当我来运行源文件时,我得到了大量的错误。
这里是源文件;
# include <iostream>
# include <graphics.h>
# include <stdlib.h>
# include <conio.h>
# include <math.h>
# include <dos.h>
class Planet
private:
int x;
int y;
int rx;
int ry;
int color;
int radius;
int position;
float displacement;
char* Buffer;
public:
Planet( ) x=y=rx=ry=radius=0;
~Planet( ) delete Buffer;
Planet(constint,constint,constint,constfloat);
void Show( );
void Move( );
void ShowOrbit( );
void GetNextPosition( );
;
Planet::Planet(constint _rx,constint _ry,constint _radius,constfloat _displacement)
rx=_rx;
ry=_ry;
x=(319+rx);
y=240;
radius=_radius;
displacement=_displacement;
position=0;
void Planet::ShowOrbit( )
setcolor(1);
ellipse(320,240,0,360,rx,ry);
void Planet::Show( )
color=(random(14)+8);
if(color==8 || color==14 || color==16)
color=(random(6)+1);
Buffer=newchar[imagesize((x-(radius+3)),(y-(radius+3)),
(x+radius+3),(y+radius+3))];
getimage((x-(radius+3)),(y-(radius+3)),(x+radius+3),(y+radius+3),Buffer);
setcolor(color);
setfillstyle(1,color);
pieslice(x,y,0,360,radius);
setcolor(11);
circle(x,y,radius);
void Planet::Move( )
putimage((x-(radius+3)),(y-(radius+3)),Buffer,0);
delete Buffer;
GetNextPosition( );
Buffer=newchar[imagesize((x-(radius+3)),(y-(radius+3)),
(x+(radius+3)),(y+(radius+3)))];
getimage((x-(radius+3)),(y-(radius+3)),(x+(radius+3)),
(y+(radius+3)),Buffer);
setcolor(color);
setfillstyle(1,color);
pieslice(x,y,0,360,radius);
setcolor((15-color));
circle(x,y,radius);
void Planet::GetNextPosition( )
float angle=(displacement*position);
x=(int)(rx*cosl(angle)+320+0.5);
y=(int)(ry*sinl(angle)+240+0.5);
if((y==240 || y==239) && x>320)
position=1;
position++;
void main( )
int driver=VGA;
int mode=VGAHI;
int error_code;
initgraph(&driver,&mode,"..\\Bgi");
error_code=graphresult( );
if(error_code!=grOk)
restorecrtmode( );
textmode(BW80);
clrscr( );
cout<<" \n Fatal Error : Graphic Driver not initialized"<<endl;
cout<<" Error Reason : "<<grapherrormsg(error_code)<<endl;
cout<<" \n Press any key to exit...";
getch( );
exit(1);
setlinestyle(0,0,3);
setcolor(7);
rectangle(0,0,getmaxx( ),getmaxy( ));
setlinestyle(0,0,0);
for(int count=0;count<5000;count++)
putpixel(random(640),random(480),random(15));
settextstyle(2,0,7);
setcolor(9);
outtextxy(15,10,"Solar");
outtextxy(16,10,"Solar");
outtextxy(16,11,"Solar");
setcolor(3);
outtextxy(72,10,"System");
outtextxy(73,10,"System");
outtextxy(73,11,"System");
setcolor(11);
outtextxy(22,27,"Simulation");
outtextxy(23,27,"Simulation");
outtextxy(23,28,"Simulation");
setcolor(7);
settextstyle(2,0,4);
outtextxy(10,465,"Press any key to exit.");
setcolor(14);
setfillstyle(1,14);
pieslice(320,240,0,360,12);
setcolor(12);
circle(320,240,12);
setcolor(4);
circle(320,240,13);
Planet Mercury(50,30,8,0.0175);
Planet Venus(80,55,8,0.0155);
Planet Earth(110,80,8,0.0135);
Planet Mars(140,105,8,0.0115);
Planet Jupiter(170,130,8,0.0095);
Planet Saturn(200,155,8,0.0075);
Planet Uranus(230,180,8,0.0055);
Planet Neptune(260,205,8,0.0035);
Planet Pluto(290,230,8,0.0015);
Mercury.ShowOrbit( );
Mercury.Show( );
Venus.ShowOrbit( );
Venus.Show( );
Earth.ShowOrbit( );
Earth.Show( );
Mars.ShowOrbit( );
Mars.Show( );
Jupiter.ShowOrbit( );
Jupiter.Show( );
Saturn.ShowOrbit( );
Saturn.Show( );
Uranus.ShowOrbit( );
Uranus.Show( );
Neptune.ShowOrbit( );
Neptune.Show( );
Pluto.ShowOrbit( );
Pluto.Show( );
do
delay(25);
Mercury.Move( );
Venus.Move( );
Earth.Move( );
Mars.Move( );
Jupiter.Move( );
Saturn.Move( );
Uranus.Move( );
Neptune.Move( );
Pluto.Move( );
while(!kbhit( ));
getch( );
closegraph( );
运行时会出现这个文件
// The winbgim library, Version 6.0, August 9, 2004
// Written by:
// Grant Macklem (Grant.Macklem@colorado.edu)
// Gregory Schmelter (Gregory.Schmelter@colorado.edu)
// Alan Schmidt (Alan.Schmidt@colorado.edu)
// Ivan Stashak (Ivan.Stashak@colorado.edu)
// Michael Main (Michael.Main@colorado.edu)
// CSCI 4830/7818: API Programming
// University of Colorado at Boulder, Spring 2003
// ---------------------------------------------------------------------------
// Notes
// ---------------------------------------------------------------------------
// * This library is still under development.
// * Please see http://www.cs.colorado.edu/~main/bgi for information on
// * using this library with the mingw32 g++ compiler.
// * This library only works with Windows API level 4.0 and higher (Windows 95, NT 4.0 and newer)
// * This library may not be compatible with 64-bit versions of Windows
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// Macro Guard and Include Directives
// ---------------------------------------------------------------------------
#ifndef WINBGI_H
#define WINBGI_H
#include <windows.h> // Provides the mouse message types
#include <limits.h> // Provides INT_MAX
#include <sstream> // Provides std::ostringstream
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// Definitions
// ---------------------------------------------------------------------------
// Definitions for the key pad extended keys are added here. When one
// of these keys are pressed, getch will return a zero followed by one
// of these values. This is the same way that it works in conio for
// dos applications.
#define KEY_HOME 71
#define KEY_UP 72
#define KEY_PGUP 73
#define KEY_LEFT 75
#define KEY_CENTER 76
#define KEY_RIGHT 77
#define KEY_END 79
#define KEY_DOWN 80
#define KEY_PGDN 81
#define KEY_INSERT 82
#define KEY_DELETE 83
#define KEY_F1 59
#define KEY_F2 60
#define KEY_F3 61
#define KEY_F4 62
#define KEY_F5 63
#define KEY_F6 64
#define KEY_F7 65
#define KEY_F8 66
#define KEY_F9 67
// Line thickness settings
#define NORM_WIDTH 1
#define THICK_WIDTH 3
// Character Size and Direction
#define USER_CHAR_SIZE 0
#define HORIZ_DIR 0
#define VERT_DIR 1
// Constants for closegraph
#define CURRENT_WINDOW -1
#define ALL_WINDOWS -2
#define NO_CURRENT_WINDOW -3
// The standard Borland 16 colors
#define MAXCOLORS 15
enum colors BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHTGRAY, DARKGRAY,
LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE ;
// The standard line styles
enum line_styles SOLID_LINE, DOTTED_LINE, CENTER_LINE, DASHED_LINE, USERBIT_LINE ;
// The standard fill styles
enum fill_styles EMPTY_FILL, SOLID_FILL, LINE_FILL, LTSLASH_FILL, SLASH_FILL,
BKSLASH_FILL, LTBKSLASH_FILL, HATCH_FILL, XHATCH_FILL, INTERLEAVE_FILL,
WIDE_DOT_FILL, CLOSE_DOT_FILL, USER_FILL ;
// The various graphics drivers
enum graphics_drivers DETECT, CGA, MCGA, EGA, EGA64, EGAMONO, IBM8514, HERCMONO,
ATT400, VGA, PC3270 ;
// Various modes for each graphics driver
enum graphics_modes CGAC0, CGAC1, CGAC2, CGAC3, CGAHI,
MCGAC0 = 0, MCGAC1, MCGAC2, MCGAC3, MCGAMED, MCGAHI,
EGALO = 0, EGAHI,
EGA64LO = 0, EGA64HI,
EGAMONOHI = 3,
HERCMONOHI = 0,
ATT400C0 = 0, ATT400C1, ATT400C2, ATT400C3, ATT400MED, ATT400HI,
VGALO = 0, VGAMED, VGAHI,
PC3270HI = 0,
IBM8514LO = 0, IBM8514HI ;
// Borland error messages for the graphics window.
#define NO_CLICK -1 // No mouse event of the current type in getmouseclick
enum graph_errors grInvalidVersion = -18, grInvalidDeviceNum = -15, grInvalidFontNum,
grInvalidFont, grIOerror, grError, grInvalidMode, grNoFontMem,
grFontNotFound, grNoFloodMem, grNoScanMem, grNoLoadMem,
grInvalidDriver, grFileNotFound, grNotDetected, grNoInitGraph,
grOk ;
// Write modes
enum putimage_ops COPY_PUT, XOR_PUT, OR_PUT, AND_PUT, NOT_PUT ;
// Text Modes
enum horiz LEFT_TEXT, CENTER_TEXT, RIGHT_TEXT ;
enum vertical BOTTOM_TEXT, VCENTER_TEXT, TOP_TEXT ; // middle not needed other than as seperator
enum font_names DEFAULT_FONT, TRIPLEX_FONT, SMALL_FONT, SANS_SERIF_FONT,
GOTHIC_FONT, SCRIPT_FONT, SIMPLEX_FONT, TRIPLEX_SCR_FONT,
COMPLEX_FONT, EUROPEAN_FONT, BOLD_FONT ;
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// Structures
// ---------------------------------------------------------------------------
// This structure records information about the last call to arc. It is used
// by getarccoords to get the location of the endpoints of the arc.
struct arccoordstype
int x, y; // Center point of the arc
int xstart, ystart; // The starting position of the arc
int xend, yend; // The ending position of the arc.
;
// This structure defines the fill style for the current window. Pattern is
// one of the system patterns such as SOLID_FILL. Color is the color to
// fill with
struct fillsettingstype
int pattern; // Current fill pattern
int color; // Current fill color
;
// This structure records information about the current line style.
// linestyle is one of the line styles such as SOLID_LINE, upattern is a
// 16-bit pattern for user defined lines, and thickness is the width of the
// line in pixels.
struct linesettingstype
int linestyle; // Current line style
unsigned upattern; // 16-bit user line pattern
int thickness; // Width of the line in pixels
;
// This structure records information about the text settings.
struct textsettingstype
int font; // The font in use
int direction; // Text direction
int charsize; // Character size
int horiz; // Horizontal text justification
int vert; // Vertical text justification
;
// This structure records information about the viewport
struct viewporttype
int left, top, // Viewport bounding box
right, bottom;
int clip; // Whether to clip image to viewport
;
// This structure records information about the palette.
struct palettetype
unsigned char size;
signed char colors[MAXCOLORS + 1];
;
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// API Entries
// ---------------------------------------------------------------------------
#ifdef __cplusplus
extern "C"
#endif
// Drawing Functions
void arc( int x, int y, int stangle, int endangle, int radius );
void bar( int left, int top, int right, int bottom );
void bar3d( int left, int top, int right, int bottom, int depth, int topflag );
void circle( int x, int y, int radius );
void cleardevice( );
void clearviewport( );
void drawpoly(int n_points, int* points);
void ellipse( int x, int y, int stangle, int endangle, int xradius, int yradius );
void fillellipse( int x, int y, int xradius, int yradius );
void fillpoly(int n_points, int* points);
void floodfill( int x, int y, int border );
void line( int x1, int y1, int x2, int y2 );
void linerel( int dx, int dy );
void lineto( int x, int y );
void pieslice( int x, int y, int stangle, int endangle, int radius );
void putpixel( int x, int y, int color );
void rectangle( int left, int top, int right, int bottom );
void sector( int x, int y, int stangle, int endangle, int xradius, int yradius );
// Miscellaneous Functions
int getdisplaycolor( int color );
int converttorgb( int color );
void delay( int msec );
void getarccoords( arccoordstype *arccoords );
int getbkcolor( );
int getcolor( );
void getfillpattern( char *pattern );
void getfillsettings( fillsettingstype *fillinfo );
void getlinesettings( linesettingstype *lineinfo );
int getmaxcolor( );
int getmaxheight( );
int getmaxwidth( );
int getmaxx( );
int getmaxy( );
bool getrefreshingbgi( );
int getwindowheight( );
int getwindowwidth( );
int getpixel( int x, int y );
void getviewsettings( viewporttype *viewport );
int getx( );
int gety( );
void moverel( int dx, int dy );
void moveto( int x, int y );
void refreshbgi(int left, int top, int right, int bottom);
void refreshallbgi( );
void setbkcolor( int color );
void setcolor( int color );
void setfillpattern( char *upattern, int color );
void setfillstyle( int pattern, int color );
void setlinestyle( int linestyle, unsigned upattern, int thickness );
void setrefreshingbgi(bool value);
void setviewport( int left, int top, int right, int bottom, int clip );
void setwritemode( int mode );
// Window Creation / Graphics Manipulation
void closegraph( int wid=ALL_WINDOWS );
void detectgraph( int *graphdriver, int *graphmode );
void getaspectratio( int *xasp, int *yasp );
char *getdrivername( );
int getgraphmode( );
int getmaxmode( );
char *getmodename( int mode_number );
void getmoderange( int graphdriver, int *lomode, int *himode );
void graphdefaults( );
char *grapherrormsg( int errorcode );
int graphresult( );
void initgraph( int *graphdriver, int *graphmode, char *pathtodriver );
int initwindow
( int width, int height, const char* title="Windows BGI", int left=0, int top=0, bool dbflag=false, bool closeflag=true );
int installuserdriver( char *name, int *fp ); // Not available in WinBGI
int installuserfont( char *name ); // Not available in WinBGI
int registerbgidriver( void *driver ); // Not available in WinBGI
int registerbgifont( void *font ); // Not available in WinBGI
void restorecrtmode( );
void setaspectratio( int xasp, int yasp );
unsigned setgraphbufsize( unsigned bufsize ); // Not available in WinBGI
void setgraphmode( int mode );
void showerrorbox( const char *msg = NULL );
// User Interaction
int getch( );
int kbhit( );
// User-Controlled Window Functions (winbgi.cpp)
int getcurrentwindow( );
void setcurrentwindow( int window );
// Double buffering support (winbgi.cpp)
int getactivepage( );
int getvisualpage( );
void setactivepage( int page );
void setvisualpage( int page );
void swapbuffers( );
// Image Functions (drawing.cpp)
unsigned imagesize( int left, int top, int right, int bottom );
void getimage( int left, int top, int right, int bottom, void *bitmap );
void putimage( int left, int top, void *bitmap, int op );
void printimage(
const char* title=NULL,
double width_inches=7, double border_left_inches=0.75, double border_top_inches=0.75,
int left=0, int right=0, int right=INT_MAX, int bottom=INT_MAX,
bool active=true, HWND hwnd=NULL
);
void readimagefile(
const char* filename=NULL,
int left=0, int top=0, int right=INT_MAX, int bottom=INT_MAX
);
void writeimagefile(
const char* filename=NULL,
int left=0, int top=0, int right=INT_MAX, int bottom=INT_MAX,
bool active=true, HWND hwnd=NULL
);
// Text Functions (text.cpp)
void gettextsettings(struct textsettingstype *texttypeinfo);
void outtext(char *textstring);
void outtextxy(int x, int y, char *textstring);
void settextjustify(int horiz, int vert);
void settextstyle(int font, int direction, int charsize);
void setusercharsize(int multx, int divx, int multy, int divy);
int textheight(char *textstring);
int textwidth(char *textstring);
extern std::ostringstream bgiout;
void outstream(std::ostringstream& out=bgiout);
void outstreamxy(int x, int y, std::ostringstream& out=bgiout);
// Mouse Functions (mouse.cpp)
void clearmouseclick( int kind );
void clearresizeevent( );
void getmouseclick( int kind, int& x, int& y );
bool ismouseclick( int kind );
bool isresizeevent( );
int mousex( );
int mousey( );
void registermousehandler( int kind, void h( int, int ) );
void setmousequeuestatus( int kind, bool status=true );
// Palette Functions
palettetype *getdefaultpalette( );
void getpalette( palettetype *palette );
int getpalettesize( );
void setallpalette( palettetype *palette );
void setpalette( int colornum, int color );
void setrgbpalette( int colornum, int red, int green, int blue );
// Color Macros
#define IS_BGI_COLOR(v) ( ((v) >= 0) && ((v) < 16) )
#define IS_RGB_COLOR(v) ( (v) & 0x03000000 )
#define RED_VALUE(v) int(GetRValue( converttorgb(v) ))
#define GREEN_VALUE(v) int(GetGValue( converttorgb(v) ))
#define BLUE_VALUE(v) int(GetBValue( converttorgb(v) ))
#undef COLOR
int COLOR(int r, int g, int b); // No longer a macro
#ifdef __cplusplus
#endif
// ---------------------------------------------------------------------------
#endif // WINBGI_H
错误
302 40 C:\Program Files\Dev-Cpp\MinGW64\include\graphics.h [Error] redefinition of 'int right'
2 0 C:\Users\user\Documents\solar.cpp In file included from C:\Users\user\Documents\solar.cpp
302 27 C:\Program Files\Dev-Cpp\MinGW64\include\graphics.h [Note] 'int right' previously declared here
28 23 C:\Users\user\Documents\solar.cpp [Error] expected ')' before ',' token
38 16 C:\Users\user\Documents\solar.cpp [Error] expected constructor, destructor, or type conversion before '(' token
C:\Users\user\Documents\solar.cpp In member function 'void Planet::Show()':
61 21 C:\Users\user\Documents\solar.cpp [Error] 'random' was not declared in this scope
66 12 C:\Users\user\Documents\solar.cpp [Error] 'newchar' was not declared in this scope
C:\Users\user\Documents\solar.cpp In member function 'void Planet::Move()':
88 12 C:\Users\user\Documents\solar.cpp [Error] 'newchar' was not declared in this scope
C:\Users\user\Documents\solar.cpp At global scope:
117 13 C:\Users\user\Documents\solar.cpp [Error] '::main' must return 'int'
C:\Users\user\Documents\solar.cpp In function 'int main()':
123 38 C:\Users\user\Documents\solar.cpp [Warning] deprecated conversion from string constant to 'char*' [-Wwrite-strings]
130 17 C:\Users\user\Documents\solar.cpp [Error] 'BW80' was not declared in this scope
130 21 C:\Users\user\Documents\solar.cpp [Error] 'textmode' was not declared in this scope
131 16 C:\Users\user\Documents\solar.cpp [Error] 'clrscr' was not declared in this scope
133 8 C:\Users\user\Documents\solar.cpp [Error] 'cout' was not declared in this scope
133 8 C:\Users\user\Documents\solar.cpp [Note] suggested alternative:
1 0 C:\Users\user\Documents\solar.cpp In file included from C:\Users\user\Documents\solar.cpp
61 18 C:\Program Files\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iostream [Note] 'std::cout'
133 67 C:\Users\user\Documents\solar.cpp [Error] 'endl' was not declared in this scope
133 67 C:\Users\user\Documents\solar.cpp [Note] suggested alternative:
39 0 C:\Program Files\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\iostream In file included from C:/Program Files/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/iostream
1 C:\Users\user\Documents\solar.cpp from C:\Users\user\Documents\solar.cpp
564 5 C:\Program Files\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\ostream [Note] 'std::endl'
149 27 C:\Users\user\Documents\solar.cpp [Error] 'random' was not declared in this scope
153 28 C:\Users\user\Documents\solar.cpp [Warning] deprecated conversion from string constant to 'char*' [-Wwrite-strings]
154 28 C:\Users\user\Documents\solar.cpp [Warning] deprecated conversion from string constant to 'char*' [-Wwrite-strings]
155 28 C:\Users\user\Documents\solar.cpp [Warning] deprecated conversion from string constant to 'char*' [-Wwrite-strings]
158 29 C:\Users\user\Documents\solar.cpp [Warning] deprecated conversion from string constant to 'char*' [-Wwrite-strings]
159 29 C:\Users\user\Documents\solar.cpp [Warning] deprecated conversion from string constant to 'char*' [-Wwrite-strings]
160 29 C:\Users\user\Documents\solar.cpp [Warning] deprecated conversion from string constant to 'char*' [-Wwrite-strings]
163 33 C:\Users\user\Documents\solar.cpp [Warning] deprecated conversion from string constant to 'char*' [-Wwrite-strings]
164 33 C:\Users\user\Documents\solar.cpp [Warning] deprecated conversion from string constant to 'char*' [-Wwrite-strings]
165 33 C:\Users\user\Documents\solar.cpp [Warning] deprecated conversion from string constant to 'char*' [-Wwrite-strings]
169 48 C:\Users\user\Documents\solar.cpp [Warning] deprecated conversion from string constant to 'char*' [-Wwrite-strings]
181 34 C:\Users\user\Documents\solar.cpp [Error] no matching function for call to 'Planet::Planet(int, int, int, double)'
181 34 C:\Users\user\Documents\solar.cpp [Note] candidates are:
26 8 C:\Users\user\Documents\solar.cpp [Note] Planet::Planet()
26 8 C:\Users\user\Documents\solar.cpp [Note] candidate expects 0 arguments, 4 provided
10 8 C:\Users\user\Documents\solar.cpp [Note] Planet::Planet(const Planet&)
10 8 C:\Users\user\Documents\solar.cpp [Note] candidate expects 1 argument, 4 provided
182 32 C:\Users\user\Documents\solar.cpp [Error] no matching function for call to 'Planet::Planet(int, int, int, double)'
182 32 C:\Users\user\Documents\solar.cpp [Note] candidates are:
26 8 C:\Users\user\Documents\solar.cpp [Note] Planet::Planet()
26 8 C:\Users\user\Documents\solar.cpp [Note] candidate expects 0 arguments, 4 provided
10 8 C:\Users\user\Documents\solar.cpp [Note] Planet::Planet(const Planet&)
10 8 C:\Users\user\Documents\solar.cpp [Note] candidate expects 1 argument, 4 provided
183 33 C:\Users\user\Documents\solar.cpp [Error] no matching function for call to 'Planet::Planet(int, int, int, double)'
183 33 C:\Users\user\Documents\solar.cpp [Note] candidates are:
26 8 C:\Users\user\Documents\solar.cpp [Note] Planet::Planet()
26 8 C:\Users\user\Documents\solar.cpp [Note] candidate expects 0 arguments, 4 provided
10 8 C:\Users\user\Documents\solar.cpp [Note] Planet::Planet(const Planet&)
10 8 C:\Users\user\Documents\solar.cpp [Note] candidate expects 1 argument, 4 provided
184 33 C:\Users\user\Documents\solar.cpp [Error] no matching function for call to 'Planet::Planet(int, int, int, double)'
184 33 C:\Users\user\Documents\solar.cpp [Note] candidates are:
26 8 C:\Users\user\Documents\solar.cpp [Note] Planet::Planet()
26 8 C:\Users\user\Documents\solar.cpp [Note] candidate expects 0 arguments, 4 provided
10 8 C:\Users\user\Documents\solar.cpp [Note] Planet::Planet(const Planet&)
10 8 C:\Users\user\Documents\solar.cpp [Note] candidate expects 1 argument, 4 provided
185 36 C:\Users\user\Documents\solar.cpp [Error] no matching function for call to 'Planet::Planet(int, int, int, double)'
185 36 C:\Users\user\Documents\solar.cpp [Note] candidates are:
26 8 C:\Users\user\Documents\solar.cpp [Note] Planet::Planet()
26 8 C:\Users\user\Documents\solar.cpp [Note] candidate expects 0 arguments, 4 provided
10 8 C:\Users\user\Documents\solar.cpp [Note] Planet::Planet(const Planet&)
10 8 C:\Users\user\Documents\solar.cpp [Note] candidate expects 1 argument, 4 provided
186 35 C:\Users\user\Documents\solar.cpp [Error] no matching function for call to 'Planet::Planet(int, int, int, double)'
186 35 C:\Users\user\Documents\solar.cpp [Note] candidates are:
26 8 C:\Users\user\Documents\solar.cpp [Note] Planet::Planet()
26 8 C:\Users\user\Documents\solar.cpp [Note] candidate expects 0 arguments, 4 provided
10 8 C:\Users\user\Documents\solar.cpp [Note] Planet::Planet(const Planet&)
10 8 C:\Users\user\Documents\solar.cpp [Note] candidate expects 1 argument, 4 provided
187 35 C:\Users\user\Documents\solar.cpp [Error] no matching function for call to 'Planet::Planet(int, int, int, double)'
187 35 C:\Users\user\Documents\solar.cpp [Note] candidates are:
26 8 C:\Users\user\Documents\solar.cpp [Note] Planet::Planet()
26 8 C:\Users\user\Documents\solar.cpp [Note] candidate expects 0 arguments, 4 provided
10 8 C:\Users\user\Documents\solar.cpp [Note] Planet::Planet(const Planet&)
10 8 C:\Users\user\Documents\solar.cpp [Note] candidate expects 1 argument, 4 provided
188 36 C:\Users\user\Documents\solar.cpp [Error] no matching function for call to 'Planet::Planet(int, int, int, double)'
188 36 C:\Users\user\Documents\solar.cpp [Note] candidates are:
26 8 C:\Users\user\Documents\solar.cpp [Note] Planet::Planet()
26 8 C:\Users\user\Documents\solar.cpp [Note] candidate expects 0 arguments, 4 provided
10 8 C:\Users\user\Documents\solar.cpp [Note] candidate expects 1 argument, 4 provided
189 34 C:\Users\user\Documents\solar.cpp [Error] no matching function for call to 'Planet::Planet(int, int, int, double)'
189 34 C:\Users\user\Documents\solar.cpp [Note] candidates are:
26 8 C:\Users\user\Documents\solar.cpp [Note] Planet::Planet()
26 8 C:\Users\user\Documents\solar.cpp [Note] candidate expects 0 arguments, 4 provided
10 8 C:\Users\user\Documents\solar.cpp [Note] Planet::Planet(const Planet&)
10 8 C:\Users\user\Documents\solar.cpp [Note] candidate expects 1 argument, 4 provided
【问题讨论】:
只是从互联网上随机复制头文件是行不通的。头文件仅描述一个接口 (API),但您还需要一个相应的实现,该实现具有与您的编译器兼容的二进制接口 (ABI)。顺便说一句:要复制错误,请尝试单击错误显示并在那里按 Control-A,尝试使用鼠标右键使用上下文菜单或搜索构建日志文件。 上面这个头文件是否兼容我自己的Dev-C++ 5.11 IDE 感谢您如何复制错误消息 【参考方案1】:设置Project Options
-> Parameters
-> Linker
为
-lbgi
-lgdi32
-lcomdlg32
-luuid
-loleaut32
-lole32
【讨论】:
项目选项未启用,请告诉我如何启用它 “项目选项未启用”是什么意思 它是灰色的你知道不是黑色我的意思是它已经在那里但它不能被鼠标击中 这可能是因为您之前运行的 prog 的某些实例仍在内存中尝试重新启动 dev c++,如果有帮助,请告诉我 我重启了还是选不上【参考方案2】:我无法发表评论,因为我没有足够的声誉,我必须留下答案,即使可能没有人需要这个了。
其他答案都是正确的,但我发现没有一个解决我知道我遇到的graphics.h
的一个问题:它在第 302 行有一个错误(在我的版本中,这似乎与你的相同)在以下声明:
void printimage(
...
int left=0, int right=0, int right=INT_MAX, int bottom=INT_MAX,
...
);
为了清楚起见,我只留下了错误所在的行。见:int right=0, int right=INT_MAX
?重新定义。您可以在您的帖子中搜索它,您会找到它。
实际上应该是这样的:
void printimage(
...
int left=0, int top=0, int right=INT_MAX, int bottom=INT_MAX,
...
);
【讨论】:
【参考方案3】:您正在处理file
,而不是project
首先下载graphics.h并将这个header放到C:\Dev-Cpp\include
二次下载Libraries,解压文件放到C:\Dev-Cpp\lib
现在,打开 Dev C++,在 File 菜单中选择 new & new project 粘贴您的代码并转到链接器参数的项目选项
lbgi
lgdi32
lcomdlg32
luuid
loleaut32
lole32
我推荐你使用Visual Studio and the same library进行图形化编程
有关graphics.h
的一些提示,另请参阅this page
【讨论】:
过去我在 Dev 和 graphics.h 方面遇到了很多问题 .... 尝试使用 Visual Studio ... 更好@alfadilahmed以上是关于Graphics.h 库不起作用的主要内容,如果未能解决你的问题,请参考以下文章