Devcpp: parse error before ';' token
I recently got Devcpp 5, for my xp. I have version 4 running on my 95, and this program compiles fine there.
Allso, where can I get non-antique headers, so it stops telling me I'm using an antique one.
Code:
#include <iostream.h>
int main()
{
cin >> int q; //Here!!!
}
ERRORS:
Code:
31 ...\Dev-Cpp\include\c++\backward\iostream.h
In file included from .../Dev-Cpp/include/c++/backward/iostream.h
1 ...\cppsource\Untitled1.cpp
from .../cppsource/Untitled1.cpp
2 ...\Dev-Cpp\include\c++\backward\backward_warning.h:32
#warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
...\cppsource\Untitled1.cpp
[Warning] In function `int main()':
5 ...\cppsource\Untitled1.cpp
parse error before `;' token
This is the modified source
:D LMAO :D
Ok, I got it. I guess any sugestions are welcome, but - I've sucesfully made the programm look the same as the structured version, except it's oop. Well, here it is:
Code:
#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;
class m
{
protected:
double pq[10], pau[10], pqq[10], pa[10], pd[10], pp[10], ps[10], pm[10]
, pu[10], pbc[10], puc[10], pu1, i, sd, aa[10][10][3]
, q, xxx, t, w, cccc, cccr, r1, r2, r3, ccc; //r1, r2 etc. = random
int x, c2, xx, a1, g;
public:
m(int);
int screen(); //main game screen
int a(); //atack routine
int bu(); //buy unuits
int bt(); //buy technology
};
m::m (int o)
{
q = o; //holds how many players there are
t = 0;
ccc = 1;
for (x=0;x<q;x++)//this sets the variables to the standard starting point
{
for(g=0;g<q;g++)
aa[x][g][0] = 0; //tracks who atacks who
pa[x] = 0; //tech affence
pd[x] = 0; //tech defence
pp[x] = 200; //population
ps[x] = 10; //states
pm[x] = 100; //money
pu[x] = 20; //units
pbc[x]=10; //unit cost
puc[x]=40; //upgrade cost
}//x is used to signify which player is playing
//this way the right arays get modified
do
{
t++; //t keeps track of turns
for (x=0; x<q; x++) //this for-loop changes the variables each time..
{
if (pp[x]==0)//if the player is dead, dont bother with the variables
continue;
srand(time(0));
r1= 1+rand() %5;
r2= 1+rand() %5;
pp[x] *=1+((r1*.75)/10.); //increas population
if (ps[x]<=10)
pm[x] += ps[x]*(pp[x]/100.); //monsy increases with the population
if (ps[x] <=7) //and states
pm[x] += (ps[x]*.7)*(pp[x]/100.);
if (ps[x]>10 && ps[x] <15)
pm[x] +=(ps[x]*.7)*(pp[x]/100.);//if the player is powerful or week,
else //the money changes inversly(power+=
pm[x] += (ps[x]/2.1)*(pp[x]/100.);//less then the week+=more then
if (ps[x]>20) //the strong) to level out the
pm[x] -= (ps[x]/5)*(pp[x]/100.);//playing field
puc[x] += (r1*2)-(r2*2); //cost to buy units and tech. changes
pbc[x] += (r1/2.)-(r2/2.);
if (pbc[x]<5)//make sure the cost dosn't go out of bounds(too much or
pbc[x]+=4;//too litle)
if (pbc[x]>20)
pbc[x]-=4;
if (puc[x]<35)
puc[x]+=10;
if (puc[x]>80)
puc[x]-=20;
}
for (x=0;x<q;x++)
{
if (pp[x]==0)
continue;//if the player is dead, dont do his turn
while(1)
{
screen();//displayes everything
cin >> pq[x];//pq is the choice the user makes(it's an aray for farther
//developemnt, needed for later ideas)
if (pq[x] == 0)
break;//ends that players turn if(0)
if (pq[x] == 1)
{
a();//atack routine
continue;
}
if (pq[x] == 2)
{
bu();//buy units
continue;
}
if (pq[x] == 3)
{
bt();//buy tech.
continue;
}
} //end while(1)
} //end if
cccc=0;
for(c2=0; c2<q; c2++)//to check if there are more then one player alive
if (pu[c2]>0)
cccc++;
}while(cccc>1);
for(c2=0; c2<q; c2++)//checks to see who won
if(ps[c2]>0){
w=c2+1; break;}
system("CLS");
cout <<"Player "<<w<<" Wins!\n";
t=0;
cout <<"Play again?(1=yes)\n";
cin >>ccc;
if (ccc!=1)
exit(1);
//a cc2();
}
int m::screen() //main game sreen
{
system("CLS");
cout <<"Player "<<x+1<<": Turn"<<t<<endl
<<"Money" <<pm[x] <<"; Pop."<<pp[x]<< "; States"<<ps[x]
<<"; Units"<< pu[x]<<endl
<<endl<<"(1)Attack, (2)Buy units"
<<"("<<pbc[x]<<")"<<", (3)Upgrade technology"<<"("<<puc[x]<<")"
<<endl<<"Tech-afence: "<<pa[x]<<" Tech-defence: "<<pd[x]
<<endl<<endl;
for (xx=0;xx<q;xx++)
{
if (pp[xx]>0)//if player isn't dead..
cout <<"Player "<<xx+1<<" States: "<<ps[xx]<<endl;
else
cout <<"Player "<<xx+1<<" is out\n";
}
cout <<endl;
for(g=0;g<q;g++)
if(aa[x][g][0] == 1){
cout <<"Player "<<g+1<<" atacked with "<<aa[x][g][1]
<<" units\n";
aa[x][g][0] = 0;}
}
int m::a() //atack routine
{
srand(time(0));
r3= 1+rand() %10;
r3/=10.;
cout <<"How many units?"<<endl;
sd=0; //used later, for deferance in units and states a1(player atacked)
cin >> pau[x];
if (pau[x] > pu[x]-ps[x])
{
cout << "Not enough units to defend your states with"<<endl;
system("PAUSE");
return 0;
}
cout<<"Whom are you attacking? "<<endl;
cin >>a1;
a1-=1;//player being attacked
if (ps[a1]==0)
{
cout <<"Player "<<a1+1<<" is out, can't attack.\n";
system("PAUSE");
return 0;
}
r3= 1+rand() %10;
r3/=10.;//used for a random outcome(within boundries)
if (r3=.5)
r3=.7;
if (r3<.5)
r3*=2;
if (r3<.5)
r3*=2;
if (r3<.5)
r3*=2;
if (r3 ==0)
r3 = 1.;
aa[a1][x][0] = 1;
aa[a1][x][1] = pau[x];
r3+=pa[x];
r3-=pd[a1];
pu[x] -=pau[x];
pu[a1] -=pau[x]*r3;//less then 1 so the atacker has the disadvantage.
//unless he has tech. afence
//and tech defence for a1 is decresed from r3
if (pu[a1]<ps[a1])//if(there are less units then states for a1)
{ //atacker gets the deference.
if (pu[a1]<=0){//incase the atacked is killed
pu1=0;
pu[x]+=pu[a1]*-1;}
else
pu1=pu[a1];
sd=pu1-ps[a1];//gets the deference
sd*=-1;
aa[a1][x][2] = sd;
if (ps[a1]/1.25<sd)//increases tech for the weeker ones
{
if (ps[a1]<=10)
pd[a1]+=.05;
if (ps[a1]/1.5<sd)
{
if (ps[a1]<=10)
pd[a1]+=.1;
if (ps[x]<=10)
pa[x]+=.05;
}
}
ps[x] += sd;//now the deference is added..
ps[a1] -=sd;//and subtrakted from the atacked.
if (pu[a1]<=10 && pu[a1]>0)//levels out the playing feild
{
//i=10-sd;
pu[a1] +=10-ps[a1];
}
}
if (pu[a1]<=0)//if dead.. set to 0
{ //revolts etc. are calculated here
pu[x]-=sd;
if (sd<2)
pu[x]-=sd;
if (sd<1)
pu[x] -=sd*2;
if (sd>9)
pu[x]-=sd*1.25;
pm[x]+=pm[a1]/5.;
pp[a1]=0;
pu[a1]=0;
pm[a1]=0;
pa[a1]=0;
pd[a1]=0;
}
}
int m::bu() //buy units
{
cout << "How manny?"<<endl;
cin >> pqq[x];
if (pqq[x]*pbc[x]>pm[x])
{
cout<<"Not enough money"<<endl;
system("PAUSE");
return 0;
}
if (pqq[x]*(pbc[x]/ps[x])>pp[x])
{
cout<<"Not enough people"<<endl;
system("PAUSE");
return 0;
}
pu[x] += pqq[x];
pm[x] -=pqq[x]*pbc[x];//decreases money and populatin per state
pp[x] -=pqq[x]*(pbc[x]/ps[x]);
}
int m::bt()
{
if (puc[x] > pm[x])
{
cout <<"Not enough money"<<endl;//a3
system("PAUSE");
return 0;
}
cout <<"Military: (1)Affence: "<<pa[x]<<", (2)Defence: "<<pd[x]<<endl;
cin >>pq[x];
if (pq[x] == 1){
pa[x]+=.1; pm[x]-=puc[x];}
if(pq[x]==2){
pd[x]+=.1; pm[x]-=puc[x];}
}
int main()
{
do{
system("CLS");
cout <<"Turn based stratagy game (text) by 1veedo: Release 12.20.3\n"
<<"I hope to have computer operated oponents soon...\n"
<<"Go back to webpages.charter.net/all/project.htm to check for later"
<<" releases.\n"
<<"\nHow many players <=10: ";
int q = 0;
cin >> q;
m a(q);
}while(1);
}
I decided to take out the class 'a' and put it in the function 'main'. I don't think it's going to my website any time soon, because I need my dad to type the password for ftp:mad: