Solved

VC++ problem with compilation.

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Purpose To explain how to place a textual stamp on a PDF document.  This is commonly referred to as an annotation, or possibly a watermark, but a watermark is generally different in that it is somewhat translucent.  Watermark’s may be text or graph…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
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 fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

747 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

13 Experts available now in Live!

Get 1:1 Help Now