编译出错,急寻帮助

straywithsmile 2005-11-29 11:53:12
由于情况复杂,我也只能大概说一下

我有Building和Controller两个类,然后我再Building的h里已经包含了Controller的h文件,然后在Building类里申明一个Controller型的成员变量,可是编译的时候编译器老是提醒我Controller未定义,请问一下这到底是怎么回事!!!
...全文
119 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
straywithsmile 2005-11-29
  • 打赏
  • 举报
回复
我用的不是全局变量,extern好像不行吧
kelinwang19 2005-11-29
  • 打赏
  • 举报
回复
用extern试试
straywithsmile 2005-11-29
  • 打赏
  • 举报
回复
我试过,声明为友元,申明为友元的地方不会报错,可是用的地方却会
straywithsmile 2005-11-29
  • 打赏
  • 举报
回复
肯定没有笔误,检查过很多次了,而且肯定insert到工程中了
level1979 2005-11-29
  • 打赏
  • 举报
回复
在 controller中添加Biulding 申明 class Biulding;
lixiaosan 2005-11-29
  • 打赏
  • 举报
回复
注意笔误,大小写等
文件是否insert到工程中
straywithsmile 2005-11-29
  • 打赏
  • 举报
回复
#include "Building.h"
#include "PersonOfFloor.h"
#include "STATUS_ENUM.h"
#include "Lift.h"
#include <VECTOR>
#include <DEQUE>
#include "Distance.h"
#include "UserInput.h"

const int MAXDISTANCE = 10001;
const bool StopLiftStartMoving = true;

using namespace std;

class Controller
{
private:
friend class Building;
friend class Lift;
public:
Controller(Building* Father = 0,int FloorOfBuilding = 1,int LiftinController = 3);
~Controller()
{
}
void Initial(int FloorAmount = 10,int LiftAmount = 3);
void AcceptOnePerson(Person*, bool IsArrived);
void RefreshLiftCommand();
void OneSecondPass();
void GetPaintInfo(vector<PaintStruct*>& PaintVec);
private:
bool DeliverToLift(Distance* CurrentDistance, int size, int FloorNumber, bool IsUp);
Person* SendPersonToLift(int CurrentFloor, LIFTSTATUS CurrentStatus);
void RebuildStopDeque();
void EmptyLiftTable();
bool DeliverUpDeque();
bool DeliverDownDeque();

void Sort(Distance* First, int size);

Building* m_ptrFatherBuilding ;
vector<FloorHashNode> m_vecPersonInBuilding ;
deque<int> m_dequeUpStop ;
deque<int> m_dequeDownStop ;
vector<Lift> m_vecLift ;
UserInput m_userInput ;
};
菜牛 2005-11-29
  • 打赏
  • 举报
回复
原来是坐电梯模拟的。

把class Controller也贴一下。
straywithsmile 2005-11-29
  • 打赏
  • 举报
回复
#ifndef MYBUILDING_WIND
#define MYBUILDING_WIND

#include "Person.h"
#include "Controller.h"
#include <VECTOR>
#include <STDLIB.H>
#include <TIME.H>
#include "PaintStruct.h"
#include "ObjectType.h"
#include "Floor.h"
#include "PersonOfFloor.h"

const float FloorHeight = 3.0f;
const int FloorAmount = 11;
const int LiftAmount = 3;

using namespace std;

class Building
{
friend class Controller;
public:

Building(int FloorAmount = 10);

~Building()
{
}
void Initial(int FloorAmount = 10,int LiftAmount = 3)
{
if(m_nFloor != FloorAmount)
{
m_nFloor = FloorAmount;
m_vecFloor.clear();
for( int i = 0; i < m_nFloor; i++)
{
Floor newFloor(FloorHeight);
m_vecFloor.push_back(newFloor);
}
//m_cController.Initial(FloorAmount,LiftAmount);
}
if(LiftAmount != m_cController.m_vecLift.size())
{
m_cController.Initial(FloorAmount,LiftAmount);
}
}

int GetFloor() const
{
return m_nFloor;
}

void OneSecondPass();

void AcceptOnePerson(Person* CurrentPerson)
{
delete CurrentPerson;
CurrentPerson = 0;
}
void InitializeSeed() const
{
srand((unsigned int) time(0));
}

int RandIn(int Low, int High) const
{
if(Low > High)
{
int Temp = Low ;
Low = High;
High = Temp;
}
int _IntervalSize = High - Low + 1;
int _RandomOffset = rand() % _IntervalSize;
return Low + _RandomOffset;
}
float GetTotalHeight(int FloorNumber) const;

float GetFloorHeight(int FloorNumber) const;

vector<PaintStruct*>& GetPaintInfo();

protected:
void RandomCreatePerson();
int RandInt() const;
void SetFloor(int nFloor)
{
if (nFloor > 0)
{
m_nFloor = nFloor;
}
}

private:
int m_nFloor;
Controller m_cController;
vector<Floor> m_vecFloor;
vector<PaintStruct*> m_paintInfo;
OBJECTTYPE m_enType;
};

#endif



--------------------Configuration: Lift1 - Win32 Debug--------------------
Compiling...
Controller.cpp
c:\documents and settings\wind.mywind\桌面\lift1\building.h(97) : error C2079: 'm_cController' uses undefined class 'Controller'
Lift.cpp
c:\documents and settings\wind.mywind\桌面\lift1\building.h(97) : error C2079: 'm_cController' uses undefined class 'Controller'
Building.cpp
main.cpp
Error executing cl.exe.

Lift1.exe - 2 error(s), 0 warning(s)


菜牛 2005-11-29
  • 打赏
  • 举报
回复
来点代码看看。

16,550

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧