#include <iostream>
using namespace std;
class State0;
class State1;
string s = "";
class State0
{
public:
State0(){}
static bool active;
static void NextState(int x, int y)
{
if (x == 0 && y == 0)
s += "0";
if (x == 0 && y == 1)
s += "1";
if (x == 1 && y == 0)
s += "1";
if (x == 1 && y == 1)
{
s += "0";
active = false;
State1::active = true;
}
}
};
class State1
{
public:
State1(){}
static bool active;
static void NextState(int x,int y)
{
if (x == 0 && y == 1)
s += "0";
if (x == 1 && y == 0)
s += "0";
if (x == 1 && y == 1)
s += "1";
if (x == 0 && y == 0)
{
s += "1";
active = false;
State0::active = true;
}
}
};
int main()
{
int i = 5;
State0::active = true;
State1::active = false;
while (i--)
{
int x, y;
cout << "Podaj x: ";
cin >> x;
cout << "Podaj y: ";
cin >> y;
if (State0::active == true)
State0::NextState(x, y);
if (State1::active == true)
State1::NextState(x, y);
}
return 0;
}
Dlaczego program mi się nie kompiluje? Przecież mam umieszczone deklaracje klasy na górze, a mam błąd: use of undefined type "State1". Piszę w Visual Studio.