|
-
October 22nd, 2005, 04:01 PM
#1
#prama once --vs-- #define
The objective here is to be able to tell when a certain file is included.
For example, suppose we have a header file named MyClass.h. In Main.cpp, we want to check if MyClass.h is included, and if not... post an error.
If we use the C-Style #define approach, you do the following in MyClass.h:
Code:
#ifndef _MYCLASS_H_
#define _MYCLASS_H_
// All code here
#endif
Now, in Main.cpp, you simply check if the file is included by doing the following:
Code:
#ifndef _MYCLASS_H_
// post error to output window, forgot the exact command at the moment
Now if we use the C++ style, which is via the #pragma directive, I have no idea how you would be able to tell if a file was included or not.
In MyClass.h:
In Main.cpp:
Any help? Thanks...
--MrDoomMaster
--C++ Game Programmer
Don't forget to rate me if I was helpful!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|