Archived

This topic is now archived and is closed to further replies.

deakin

classes and stuff

Recommended Posts

This is a really dumb question, but I can''t seem to work out what to do.... Say I have a class declared in Whatever.h and defined in Whatever.cpp how can it be accessed by other .h files? (I know it can be accessed by other .cpp files because they can include Whatever.h, but everyone says that .h files shouldnt include other .h files) Thanks in advance, - Daniel

my homepage

Share this post


Link to post
Share on other sites
quote:
Original post by deakin

... but everyone says that .h files shouldnt include other .h files)




I don''t think that everybody says this . As long as you have the standard

#ifndef MY_HEADER
#define MY_HEADER
...
#endif

in each of your headers to prevent multiple includes you should be ok. There should be no problems with .h files including other .h files.

Another posibilty could be to group similar classes in one header file but I prefer the one class per header idea.


Andrew

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You don''t want to open up namespaces in .h-files though.
Try to use the explicit syntax in that case. (instead of "using" directive, use scope resolution).
If you don''t use namespaces, ignore me

A polar bear is a rectangular bear after a coordinate transform.

Share this post


Link to post
Share on other sites