次のコードをご覧ください
GameObject.h
#pragma once
class GameObject
{
protected:
int id;
public:
int instances;
GameObject(void);
~GameObject(void);
virtual void display();
};
GameObject.cpp
#include "GameObject.h"
#include <iostream>
using namespace std;
static int value=0;
GameObject::GameObject(void)
{
value++;
id = value;
}
GameObject::~GameObject(void)
{
}
void GameObject::display()
{
cout << "Game Object: " << id << endl;
}
Round.h
#pragma once
#include "GameObject.h"
class Round :
public GameObject
{
public:
Round(void);
~Round(void);
};
Round.cpp
#include "Round.h"
#include "GameObject.h"
#include <iostream>
using namespace std;
Round::Round(void)
{
}
Round::~Round(void)
{
}
void display()
{
cout << "Round Id: " << id;
}
クラス'id' : undeclared identifier
でエラーが 発生します。Round
どうしてこれなの?助けてください!