By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,234 Members | 1,872 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,234 IT Pros & Developers. It's quick & easy.

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

P: n/a
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 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
* Bi**********@gmail.com:
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?
Mar 15 '07 #2

P: n/a
On Mar 15, 1:27 pm, "Alf P. Steinbach" <a...@start.nowrote:
* Biermann....@gmail.com:
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 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.