FAQ lite:10.19, Bar() part is declaring a non-member function that returns a Bar object

Discussion in 'C++' started by Biermann.Pan@gmail.com, Mar 15, 2007.

  1. Guest

    Hi all,
    I dont' understand the statement in 10.19 of C++ FAQ lite,
    I have never seen a function can be declared as Bar(),

    according to my experience, all functions are declared in form of

    return_type func_name(parametes_list);

    if Bar is the return type, where is the func_name?
    or if Bar is the func_name, where is the return_type as the Author
    says it's non member of function, it should have a return_type because
    non-member function should not be ctor/dtor witouth return_type.

    please help me understand the statement. thanks in advance.
     
    , Mar 15, 2007
    #1
    1. Advertising

  2. Re: FAQ lite:10.19, Bar() part is declaring a non-member functionthat returns a Bar object

    * :
    > Hi all,
    > I dont' understand the statement in 10.19 of C++ FAQ lite,
    > I have never seen a function can be declared as Bar(),
    >
    > according to my experience, all functions are declared in form of
    >
    > return_type func_name(parametes_list);
    >
    > if Bar is the return type, where is the func_name?


    None needed as a formal argument.

    Compare:

    void foo( int ); // No argument name.
    void foo2( int x ); // With dummy argument name.
    void goo( Bar() ); // No argument name.
    void goo2( Bar x() ); // With dummy argument name.

    The latter is equivalent to

    void goo2( Bar (*x)() );

    which means x is pointer to a function taking no arguments and returning
    a Bar.

    Which in turn is equivalent to (by removing the unnecessary argument name)

    void goo2( Bar(*x)() );

    Now peruse your compiler's standard library headers for the definition
    of 'signal'...

    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is it such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
     
    Alf P. Steinbach, Mar 15, 2007
    #2
    1. Advertising

  3. Guest

    On Mar 15, 1:27 pm, "Alf P. Steinbach" <> wrote:
    > * :
    >
    > > Hi all,
    > > I dont' understand the statement in 10.19 of C++ FAQ lite,
    > > I have never seen a function can be declared as Bar(),

    >
    > > according to my experience, all functions are declared in form of

    >
    > > return_type func_name(parametes_list);

    >
    > > if Bar is the return type, where is the func_name?

    >
    > None needed as a formal argument.
    >
    > Compare:
    >
    > void foo( int ); // No argument name.
    > void foo2( int x ); // With dummy argument name.
    > void goo( Bar() ); // No argument name.
    > void goo2( Bar x() ); // With dummy argument name.
    >
    > The latter is equivalent to
    >
    > void goo2( Bar (*x)() );
    >
    > which means x is pointer to a function taking no arguments and returning
    > a Bar.
    >
    > Which in turn is equivalent to (by removing the unnecessary argument name)
    >
    > void goo2( Bar(*x)() );
    >
    > Now peruse your compiler's standard library headers for the definition
    > of 'signal'...

    thanks, ic now, it is the rule the argument can be omitted applied on
    an argument of function pointer.
    >
    > --
    > A: Because it messes up the order in which people normally read text.
    > Q: Why is it such a bad thing?
    > A: Top-posting.
    > Q: What is the most annoying thing on usenet and in e-mail?
     
    , Mar 15, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. slide_o_mix
    Replies:
    0
    Views:
    444
    slide_o_mix
    Oct 15, 2003
  2. Alex
    Replies:
    0
    Views:
    411
  3. Aaron Brady

    SQL, lite lite lite

    Aaron Brady, Dec 29, 2008, in forum: Python
    Replies:
    15
    Views:
    792
    Aaron Brady
    Jan 1, 2009
  4. Markus S
    Replies:
    2
    Views:
    389
    Markus S
    Jul 13, 2009
  5. ittium
    Replies:
    5
    Views:
    461
    88888 Dihedral
    Jan 12, 2012
Loading...

Share This Page