Advertisement

classes and stuff

Started by April 07, 2000 08:40 PM
1 comment, last by deakin 24 years, 8 months ago
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
- DanielMy homepage
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
Advertisement
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.

This topic is closed to new replies.

Advertisement