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

B

Biermann.Pan

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.
 
A

Alf P. Steinbach

* (e-mail address removed):
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'...
 
B

Biermann.Pan

* (e-mail address removed):





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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top