header include structure

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • marsboee

    header include structure

    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
  • Josh Sebastian

    #2
    Re: header include structure

    On Thu, 11 Sep 2003 16:37:20 -0700, marsboee wrote:
    [color=blue]
    > 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.[/color]

    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

    Comment

    • Sandeep

      #3
      Re: header include structure

      It is perfectly fine to include the class header file even if
      you are just interested in one of the structures.

      Checkout the following article about header file inclusion:



      Sandeep
      --
      Sequence diagram based systems engineering and architecture design tool. Built in support for alternative scenarios and multi-tier architectures.

      EventStudio 2.0 - Generate Sequence Diagrams and Use Cases in PDF

      Comment

      • jeffc

        #4
        Re: header include structure


        "marsboee" <aaron_mars@yah oo.com> wrote in message
        news:18b09776.0 309111537.7900d 999@posting.goo gle.com...[color=blue]
        > 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.[/color]

        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.


        Comment

        Working...