Solved

VC++ problem with compilation.

Posted on 2006-06-20
4
260 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
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 …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

914 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now