im getting this now when i try to put it throughout the code...
Code:
[montez@localhost codes]$ c++ game.cpp -o game -O2 -Wall
game.cpp: In function `void intro(stats&)':
game.cpp:29: error: syntax error before `&' token
game.cpp: In function `int main(stats&)':
game.cpp:38: error: syntax error before `&' token
game.cpp: In function `void name(stats&)':
game.cpp:45: error: syntax error before `&' token
game.cpp: In function `void station(stats&)':
game.cpp:62: error: syntax error before `&' token
game.cpp:66: error: syntax error before `&' token
and my code is:
Code:
#include <iostream>
using namespace std;
struct stats { //declairs a structure that holds the player information
string name; //players name
string weapon; //players weapon
int life; //players life
int debt; //players debt to loanshark
};
void intro(stats &S);
void name(stats &S);
void station(stats &S);
void atlanta(stats &S);
void loanshark(stats &S);
void intro(stats &S) {
cout<<"--------------------------------------------- "<<endl;
cout<<"---- ---- "<<endl;
cout<<"---- ---- "<<endl;
cout<<"---- -Drug Wars- ---- "<<endl;
cout<<"---- ---- "<<endl;
cout<<"---- ---- "<<endl;
cout<<"---- -By: Goosie- ---- "<<endl;
cout<<"---- ---- "<<endl;
cout<<"---- ---- "<<endl;
cout<<"--------------------------------------------- "<<endl;
name(stats &S);
}
int main(stats &S) {
stats player;
S.life = 100;
S.debt = 500;
intro(stats &S);
}
void name(stats &S) {
cout<<"Enter your name: ";
cin>>S.name;
station(stats &S);
}
void station(stats &S) {
int destination;
cout<<"Train Station... "<<endl;
cout<<"Pick a destination: "<<endl;
cout<<"--------------------------- "<<endl;
cout<<"1. Loan Shark "<<endl;
cout<<"2. Atlanta "<<endl;
cout<<"Where do you want to go? ";
cin>>destination;
switch ( destination ) {
case 1:
cout<<"You catch the Greyhound headed towards your loan shark. "<<endl<<endl;
loanshark(stats &S);
break;
case 2:
cout<<"You catch the MARTA headed towards Atlanta. "<<endl<<endl;
atlanta(stats &S);
break;
default:
cout<<"Invalid destination... ";
break;
}
cin.get();
}
void atlanta(stats &S) {
cout<<"Atlanta is incomplete right now, sorry "<<endl;
}
void loanshark(stats &S) {
cout<<"You are at the loan sharks office, and "<<endl;
cout<<"currently owe him $"<<S.debt<<". "<<endl;
cout<<"How much do you want to repay the loan "<<endl;
cout<<"shark now?"<<endl;
}
i decided to turn it into a drugwars clone... ive always loved that game