header include structure

M

marsboee

This must have been the MFC (or basic C++) class I slept through:

I have a typedef in a header file (for a CView subclass). I want to
use this type in another .h file.

How do I make this type available to another header (as a member
variable, for instance)? It (obviously) works to just include the .h
file with the typedef in the desired header, but I know this is bad
style and might cause problems in the future.

Thanks,
marsboee
 
J

Josh Sebastian

This must have been the MFC (or basic C++) class I slept through:

I have a typedef in a header file (for a CView subclass). I want to
use this type in another .h file.

How do I make this type available to another header (as a member
variable, for instance)? It (obviously) works to just include the .h
file with the typedef in the desired header, but I know this is bad
style and might cause problems in the future.

No, it's not bad style. It's what you do. Alternatively, you could
duplicate the typedef in the other header, but that /is/ bad style and
might cause problems in the future. :-}

Josh
 
J

jeffc

marsboee said:
This must have been the MFC (or basic C++) class I slept through:

I have a typedef in a header file (for a CView subclass). I want to
use this type in another .h file.

How do I make this type available to another header (as a member
variable, for instance)? It (obviously) works to just include the .h
file with the typedef in the desired header, but I know this is bad
style and might cause problems in the future.

Why is it "bad style"? Unless you are talking about namespaces keeping
things cleaner, but even so those have to go into header files too if you're
going to use them in multiple places.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,141
Messages
2,570,817
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top