Solved

VC++ problem with compilation.

Posted on 2006-06-20
4
264 Views
Last Modified: 2010-04-17
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
Comment
Question by:ritika_pande
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 250 total points
ID: 16940370
//#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
 

Author Comment

by:ritika_pande
ID: 16941084
Hi,

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

Regards
Ritika
0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is about my first experience with programming Arduino.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Six Sigma Control Plans

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question