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

    [RESOLVED] Initialisation Lists

    Hi, was just going through my uni notes and found a question I can't find the answer to.

    What is the difference between the following?

    Code:
    TextBox (const string &text, const Vector2f &position, bool visible) :
           _text(text), _position(position), _visible(visible) {}
    And

    Code:
    TextBox (const string &text, const Vector2f &position, bool visible) :
           _position(position), _text(text), _visible(visible) {}
    does it actually make a difference?

  2. #2
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: Initialisation Lists

    There is no difference since the order of construction of member variables depends on their order of declaration in the class definition.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  3. #3
    Join Date
    Apr 2009
    Posts
    20

    Re: [RESOLVED] Initialisation Lists

    thank you.

  4. #4
    Join Date
    Feb 2009
    Posts
    56

    Re: [RESOLVED] Initialisation Lists

    If you open up your compiler then you may find the difference in the orders of variable initialization and nothing more than writing a+b in place of b+a.
    -----

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