• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 272
  • Last Modified:

VC++ problem with compilation.

Hi,

I have a class CTop which has a member pointer of CBot type. CBot type in turn has an a member which is a pointer to CTop class. Including the header file on one in another I am not able to compile. Could you suggest a simple solution to this problem.

Example :

BotFile.h is as
#ifndef BOTFILE_HEADER
#define BOTFILE_HEADER

#include ".\TopFile.h"
class CBotFile
{
private:
      CTopFile* m_pTopFile;
 ....
};
#endif
------------------------------------------------------------------------------------------------
TopFile.h is as:
#ifndef TOPFILE_HEADER
#define TOPFILE_HEADER
#include ".\BotFile.h"
class CTopFile
{
private:
      CBotFile* m_pBotFile;
 ....
};
#endif

While compiling TopFile.cpp I get this Error in BotFile.h
------------------------------------------------------------------

CTopFile* m_pTopFile;
d:\LearnC++\NewProj\NewProj\BotFile.h(13): error C2143: syntax error : missing ';' before '*'


Please help me find a soluation to this problem...

Thanks in advance.
Ritika      













0
ritika_pande
Asked:
ritika_pande
1 Solution
 
AlexFMCommented:
//#include ".\TopFile.h"
class CTopFile;              // forward declaration
class CBotFile
{
private:
     CTopFile* m_pTopFile;
 ....
};


//#include ".\BotFile.h"
class CBotFile;              // forward declaration
class CTopFile
{
private:
     CBotFile* m_pBotFile;
 ....
};

Include both headers to cpp files.
0
 
ritika_pandeAuthor Commented:
Hi,

Thanks for the response. I tried it and it workled for me in a more complex situation too.

Regards
Ritika
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now