Solved

VC++ problem with compilation.

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupSumClump challenge 9 115
python question 5 76
Eclipse Neon start with Admin account only 6 121
cmd.exe will not close when running .bat file to perform FTP upload 18 100
A short article about problems I had with the new location API and permissions in Marshmallow
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
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 …

808 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