?
Solved

need help with a single #include statement that gives 102 errors!

Posted on 2003-03-08
7
Medium Priority
?
158 Views
Last Modified: 2013-11-20
hi all,

in a .cpp file created for implementing member functions of the View class
i put: #include "CMyView.h"

and a bunch of errors appear.

The same happens if i try to include the Document class.

Only 8 errors appear when using #include "StdAfx.h" before the other.

would appreciate any kind of help :)
0
Comment
Question by:basil001
[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
  • 2
7 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 320 total points
ID: 8096862
The standard set of #include lines in MFC View class is:

#include "stdafx.h"
#include "SampleApp.h"           // application

#include "SampleDoc.h"           // document
#include "SampleView.h"          // view

If yoy have such include lines and still have errors, give additional information.
0
 

Author Comment

by:basil001
ID: 8098252
Those includes appear on the View class .cpp file

but i want to implement function members of the class in a separate .cpp file, to keep the SampleView.cpp not very long.

So i create a .cpp file, include the View Class header function SampleView.h, and still the same lot of errors; even if only the "#include SampleView.h" exists in the cpp file created.

AH, it works if the four includes are inserted on the new .cpp:

#include "stdafx.h"
#include "SampleApp.h"           // application
#include "SampleDoc.h"           // document
#include "SampleView.h"          
 
Is this the normal procedure to follow when you want to implement class function members on different files?

thanks
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 8100961
If it works, it is the normal procedure.
0
 

Expert Comment

by:sigmazero13
ID: 8104245
what are some of the errors?  Remember, if a header file is included more than once in a compile, it can give you errors about redefinitions.  For instance, if SampleView.h above has the following:

#include "SampleDoc.h"

and your main program has the includes you listed, you could get errors because you are basically including SampleDoc.h twice.

However, a good practice to do in a .h file is this:

// SampleDoc.h

#ifndef SAMPLEDOC_H
#define SAMPLEDOC_H

...  // put everything else here

#endif

When you create a class with the ClassWizard, it will generate this for you, but use some long weird string.  Basically, what it's doing is only including the file if it hasn't been included yet.  It checks if it has a definition for SAMPLEDOC_H, and if it does, it skips everything between the #ifndef and #endif

The only catch is that you MUST make sure that every header file in your compile has a different definition.  I like to use the filename, with an underscore replacing the dot, but it can be anything as long as it is unique from any other file you are including.

If this isn't the problem, try listing some of your errors and maybe that will help
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

765 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