CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2009
    Posts
    8

    Arrow #include questions: a class included many times things work fine ?

    i have a class inherited from base class cobjec
    i include many h files to test it in console. FINE everything fine, I smile!

    but then i leave my class into a dialog based application, delete afxwin.h and other afx...h
    i got abunch of errors at the base class functions, i stop laughing.

    how to fix this , how to test this

    could someone help me please, i am new to this


    thanks a lot

  2. #2
    Join Date
    Jun 2009
    Location
    France
    Posts
    2,513

    Re: #include questions: a class included many times things work fine ?

    Your .h files need "include guards". Also, if you create function, or implement methods inside those .h files, then you need to declare them inline.

    Without those, your code works fine, but if you include it more than once, everything crashes.

  3. #3
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: #include questions: a class included many times things work fine ?

    Quote Originally Posted by monarch_dodra View Post
    Your .h files need "include guards".
    Lack of these will cause compile errors.

    Also, if you create function, or implement methods inside those .h files, then you need to declare them inline.
    Or else you'll get linker errors.

    Without those, your code works fine, but if you include it more than once, everything crashes.
    I prefer to reserve the term "crash" for runtime problems, personally.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured