Making Variables work in Multiple functions
How can I make Variables work in multiple functions?
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
#include <iostream>
using namespace std;
class PlayerMove{
public:
void displayBoard(){
string sp1, sp2, sp3, sp4, sp5, sp6, sp7, sp8, sp9;
cout << "[" << sp1 << "][" << sp2 << "][" << sp3 << "]" << endl
<< "[" << sp4 << "][" << sp5 << "][" << sp6 << "]" << endl
<< "[" << sp7 << "][" << sp8 << "][" << sp9 << "]" << endl;
}
};
int main(){
PlayerMove playerObject;
playerObject.displayBoard();
int exit;
cin >> exit;
return 0;
}
|
I want the variables sp1 - sp9 to work in all functions. How can I get this to work?
Topic archived. No new replies allowed.