Mail Archives: djgpp/1999/10/25/02:17:56
From: | "Philip Bock" <bockfam AT icenter DOT net>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | I get an error, but don't see why...
|
Lines: | 169
|
X-Priority: | 3
|
X-MSMail-Priority: | Normal
|
X-Newsreader: | Microsoft Outlook Express 5.00.2314.1300
|
X-MimeOLE: | Produced By Microsoft MimeOLE V5.00.2314.1300
|
Message-ID: | <zXPQ3.20115$5i5.770016@typhoon.mbnet.mb.ca>
|
Date: | Mon, 25 Oct 1999 03:15:43 GMT
|
NNTP-Posting-Host: | 207.161.236.39
|
X-Trace: | typhoon.mbnet.mb.ca 940821343 207.161.236.39 (Sun, 24 Oct 1999 22:15:43 CDT)
|
NNTP-Posting-Date: | Sun, 24 Oct 1999 22:15:43 CDT
|
Organization: | MBnet Networking Inc.
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
I have what looks to me like perfectly good code, but still get your typical
cryptic error message...
Anyone have any ideas?
Errors:
vector.cpp: In method `shape::shape(int, int, int)':
vector.cpp:134: parse error before `;'
vector.cpp:137: warning: ANSI C++ forbids declaration `stype' with no type
or storage class
vector.cpp:137: confused by earlier errors, bailing out
Source code:
#include <allegro.h>
#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
struct coord
{
int x, y;
};
struct vector
{
coord c1, c2;
int color;
};
struct shape
{
int numvects;
int stype;
int sfill;
vector *vects;
shape(int newnumvects, int newstype, int newsfill);
};
struct vimg
{
int numvectors, numshapes;
vector *vectors;
shape *shapes;
vimg(int nnumv, int nnums, int vpers[]);
};
void program_init(void);
void draw_vimg(vimg vectimg);
vimg *gen_vimg(void);
file://shape::shape(int newnumvects, int newstype, int newsfill);
file://vimg::vimg(int nnumv, int nnums);
int main(void)
{
// program_init();
// set_gfx_mode(GFX_VESA1, 640, 480, 0, 0);
vimg *mygraphic;
mygraphic = gen_vimg();
// draw_vimg(mygraphic);
// set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
}
void program_init(void)
{
clrscr();
gotoxy(37, 1);
cout << "Atest1\n";
cout << "Initializing Allegro library...\n";
allegro_init();
cout << "Setting up timer...\n";
install_timer();
cout << "Initializing mouse routines...";
if (install_mouse() == -1)
cout << "failed\n";
else
cout << '\n';
cout << "Detected Operating System: ";
if (os_type == OSTYPE_UNKNOWN)
cout << "MS-DOS\n";
if (os_type == OSTYPE_WIN95)
cout << "Windows 95\n";
if (os_type == OSTYPE_DOSEMU)
cout << "Linux DOSEMU\n";
}
void draw_vimg(vimg vectimg, int x, int y, int xscale, int yscale)
{
for(int a = 0; a != vectimg.numshapes; a++)
{
file://Code to draw one shape's outline
for(int b = 0; b != vectimg.shapes[a].numvects; b++)
line(screen, (vectimg.shapes[a].vects[b].c1.x*xscale)+x,
(vectimg.shapes[a].vects[b].c1.y*yscale)+y,
(vectimg.shapes[a].vects[b].c2.x*xscale)+x,
(vectimg.shapes[a].vects[b].c2.y*yscale)+y,
vectimg.shapes[a].vects[b].color);
// Code to fill shape goes here.
}
}
vimg *gen_vimg(void)
{
int vpers[]={6};
vimg newvimg(6, 1, vpers);
newvimg.vectors[0].c1.x = 50;
newvimg.vectors[0].c1.y = 1;
newvimg.vectors[0].c2.x = 100;
newvimg.vectors[0].c2.y = 1;
newvimg.vectors[0].color = 1;
newvimg.vectors[1].c1.x = 100;
newvimg.vectors[1].c1.y = 1;
newvimg.vectors[1].c2.x = 150;
newvimg.vectors[1].c2.y = 50;
newvimg.vectors[1].color = 1;
newvimg.vectors[2].c1.x = 150;
newvimg.vectors[2].c1.y = 50;
newvimg.vectors[2].c2.x = 100;
newvimg.vectors[2].c2.y = 100;
newvimg.vectors[2].color = 1;
newvimg.vectors[3].c1.x = 100;
newvimg.vectors[3].c1.y = 100;
newvimg.vectors[3].c2.x = 50;
newvimg.vectors[3].c2.y = 100;
newvimg.vectors[3].color = 1;
newvimg.vectors[4].c1.x = 50;
newvimg.vectors[4].c1.y = 100;
newvimg.vectors[4].c2.x = 1;
newvimg.vectors[4].c2.y = 50;
newvimg.vectors[4].color = 1;
newvimg.vectors[5].c1.x = 1;
newvimg.vectors[5].c1.y = 50;
newvimg.vectors[5].c2.x = 50;
newvimg.vectors[5].c2.y = 1;
newvimg.vectors[5].color = 1;
newvimg.shapes[0].vects[0] = newvimg.vectors[0];
newvimg.shapes[0].vects[1] = newvimg.vectors[1];
newvimg.shapes[0].vects[2] = newvimg.vectors[2];
newvimg.shapes[0].vects[3] = newvimg.vectors[3];
newvimg.shapes[0].vects[4] = newvimg.vectors[4];
newvimg.shapes[0].vects[5] = newvimg.vectors[5];
}
shape::shape(int newnumvects, int newstype, int newsfill);
{
numvects = newnumvects;
stype = newstype;
sfill = newsfill;
vects = new vector * [newnumvects];
}
vimg::vimg(int nnumv, int nnums, int vpers[]);
{
numvectors = nnumv;
numshapes = nnums;
vectors = new vector [nnumv];
shapes = new *shape [nnums];
for (int c = 0; c != nnums; c++)
shapes[c] = new shape(vpers[c], 0, 0);
}
- Raw text -