Justice wrote:
> I am trying to make a simple game but have some problems
>
> here is the code so far
>
[SNIP]
>
> int main()
> {
>
[SNIP]
> player Main; // CREATE MAIN CHAR
[SNIP]
> cout << "Would you like to visit the store? ";
> cin >> Store;
> if (Store='y')
> {
>
> STORE(Gold);
> }
[SNIP]
>
> return 0;
> }
[SNIP]
> void STORE(int Gold)
> {
> char Buy;
> int Item;
> char Sell;
> string Wepon;
> string armor;
>
> system ("cls");
> cout << "We have " << endl;
> cout << "1 - Dagger----------------50 gp" << endl;
> cout << "2 - Short Sword----------100 gp" << endl;
> cout << "3 - Long Sword-----------150 gp" << endl;
> cout << "4 - Leather Armor--------200 gp" << endl;
> cout << "5 - Sheld-----------------50 gp" << endl;
>
> cout << "Would you like to buy anyting?(y/n)" << endl;
> cin >> Buy;
> if (Buy='y')
> {
> cout << "what would you like" << endl;
> cin >> Item;
> PURCHICE(Item);
> }
> else
> {
> cout << "Would you like to sell anything" << endl;
> cin >> Sell;
> if (Sell='y')
> {
> Wepon=Main.DISPLAY_WEPON();
> Armor=Main.DISPLAY_ARMOR();
> cout << "What would you like to sell" << endl;
> cout << "1 - " << Wepon << endl;
> cout << "2 - " << Armor << endl;
> cin >> Item;
> SELL(Item);
> }
> }
>
> }
>
>
> --------------------Configuration: GAMEv001 - Win32
> Debug--------------------
> Compiling...
> gamev001.cpp
> c:\do***ents and settings\justice\gamev001\gamev001.cpp(345) : error
> C2065: 'Main' : undeclared identifier
This is what I tried to show by snipping unrelated code. The variable
Main
is declaired in the function main(). It is therefor local to the function
main. Outside of main it doesn't exist.
Your function Store attempts to use the variable Main, but Main doesn't
exist in it. One way to make Store see Main is to pass it as a parameter.
Since you'll be wanting to change Main you'll want to pass a reference to
it. So, change the signature of Store:
void STORE(player& Main, int Gold)
and in main call STORE like:
STORE(Main, Gold);
This is the main error I found, but looking at your other errors, you
probably have to do the same thing with Armor, pass it in.
> c:\do***ents and settings\justice\gamev001\gamev001.cpp(345) : error
> C2228: left of '.DISPLAY_WEPON' must have class/struct/union type
> c:\do***ents and settings\justice\gamev001\gamev001.cpp(346) : error
> C2065: 'Armor' : undeclared identifier
> c:\do***ents and settings\justice\gamev001\gamev001.cpp(346) : error
> C2228: left of '.DISPLAY_ARMOR' must have class/struct/union type
> Error executing cl.exe.
>
> GAMEv001.exe - 4 error(s), 0 warning(s)
--
Jim Langston
tazmaster@[EMAIL PROTECTED]


|