Im new to programming, i'm running out of time i need someone to help me to fix this code. This is monopoly code, after i made 2 player, it gone wrong, if there is another way to make 2player, plz tell me . thx
actual error
1>------ Build started: Project: fromscratch, Configuration: Debug Win32 ------
1> main.cpp
1>c:\users\vengeur\documents\visual studio 2010\projects\fromscratch\fromscratch\main.cpp(11): error C2065: 'player' : undeclared identifier
1>c:\users\vengeur\documents\visual studio 2010\projects\fromscratch\fromscratch\main.cpp(11): error C2146: syntax error : missing ')' before identifier 'play'
1>c:\users\vengeur\documents\visual studio 2010\projects\fromscratch\fromscratch\main.cpp(11): error C2182: 'func_pos' : illegal use of type 'void'
1>c:\users\vengeur\documents\visual studio 2010\projects\fromscratch\fromscratch\main.cpp(11): error C2059: syntax error : ')'
1>c:\users\vengeur\documents\visual studio 2010\projects\fromscratch\fromscratch\main.cpp(120): error C2365: 'func_pos' : redefinition; previous definition was 'data variable'
1> c:\users\vengeur\documents\visual studio 2010\projects\fromscratch\fromscratch\main.cpp(11) : see declaration of 'func_pos'
1>c:\users\vengeur\documents\visual studio 2010\projects\fromscratch\fromscratch\main.cpp(126): warning C4554: '&' : check operator precedence for possible error; use parentheses to clarify precedence
1>c:\users\vengeur\documents\visual studio 2010\projects\fromscratch\fromscratch\main.cpp(145): warning C4554: '&' : check operator precedence for possible error; use parentheses to clarify precedence
1>c:\users\vengeur\documents\visual studio 2010\projects\fromscratch\fromscratch\main.cpp(188): warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data
1>c:\users\vengeur\documents\visual studio 2010\projects\fromscratch\fromscratch\main.cpp(195): error C2065: 'play' : undeclared identifier
1>c:\users\vengeur\documents\visual studio 2010\projects\fromscratch\fromscratch\main.cpp(195): error C2228: left of '.position' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\vengeur\documents\visual studio 2010\projects\fromscratch\fromscratch\main.cpp(197): error C2275: 'player' : illegal use of this type as an expression
1> c:\users\vengeur\documents\visual studio 2010\projects\fromscratch\fromscratch\main.cpp(21) : see declaration of 'player'
1>c:\users\vengeur\documents\visual studio 2010\projects\fromscratch\fromscratch\main.cpp(197): error C2146: syntax error : missing ')' before identifier 'play'
1>c:\users\vengeur\documents\visual studio 2010\projects\fromscratch\fromscratch\main.cpp(197): error C2059: syntax error : ')'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
A very useless description of the errors. What's your compiler telling you?
Here's a few things anyway:
1. move this: void func_pos(player play);
BELOW your struct delclaration for player (which starts on line 21)
2. This: if( play.position != 0 & square[ x ].owner == 0)
needs 2 ampersands, not one. I'd also put some brackets in to make sure you are checking exactly what you think you are checking.
3. This: play.position += d;
You have not told your compiler what a "play" is.
4. This: func_pos(player play);
You dont need to pass the type in.
(Looks like on line 194 you want something like this:
player play;
5. you have told your compiler that who_start() returns an int, but your method does not do this.
here is my working single player, could you just add to it second player or reference where i can find that cod eplz i dont have time to fix codes, the previous code is ruined badly
#include <iostream>
#include <ctime>
#include <string>
using namespace std;
void declare();
int dice();
void func_pos();
struct places {
string name;
int price;
int rent;
int number;
int owner;
};