Results 1 to 9 of 9

Thread: Doubt regarding 'Find Files' example - No forward declaration of class?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Doubt regarding 'Find Files' example - No forward declaration of class?

    The Google C++ Style Guide (link) has some good information.

    Here's what it says about forward declarations:
    How can we use a class Foo in a header file without access to its definition?

    We can declare data members of type Foo* or Foo&.
    We can declare (but not define) functions with arguments, and/or return values, of type Foo. (One exception is if an argument Foo or const Foo& has a non-explicit, one-argument constructor, in which case we need the full definition to support automatic type conversion.)
    We can declare static data members of type Foo. This is because static data members are defined outside the class definition.

    On the other hand, you must include the header file for Foo if your class subclasses Foo or has a data member of type Foo.

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Doubt regarding 'Find Files' example - No forward declaration of class?

    One golden tip I can give is:
    Don't rely on include files including other files.
    Always try to explicitly include the header or forward declaration of any class you use.

    In that respect, and my personal opinion, the example isn't 100% correct.

  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Doubt regarding 'Find Files' example - No forward declaration of class?

    You surely find all header files on your disk, where you have installed Qt. That should be the fastest and easiest why to find the files.

Similar Threads

  1. Forward Declaration of struct QCloseEvent ????
    By drake1983 in forum Newbie
    Replies: 2
    Last Post: 3rd February 2009, 15:16
  2. problem with forward declaration
    By MarkoSan in forum General Programming
    Replies: 14
    Last Post: 6th January 2008, 21:45
  3. Forward Class declaration ERROR
    By nleverin in forum Qt Programming
    Replies: 1
    Last Post: 30th July 2007, 08:35
  4. Forward declaration with std namespace
    By Raistlin in forum General Programming
    Replies: 2
    Last Post: 5th March 2007, 20:45
  5. Why forward declaration ?
    By probine in forum General Programming
    Replies: 3
    Last Post: 26th January 2007, 18:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.