Name look up rules



 DEVELOP > c-Plus-Plus > Name look up rules

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "puzzlecracker"
Date: 23 Aug 2006 06:16:41 PM
Object: Name look up rules
example is taken from Evolution of C++.
I don't understand how the following will be interpreted:
typedef int P();
typedef int Q();
class X{
static P(Q);
static Q(P);
};
Thanks
.

User: "Victor Bazarov"

Title: Re: Name look up rules 23 Aug 2006 07:21:35 PM
puzzlecracker wrote:

example is taken from Evolution of C++.

I don't understand how the following will be interpreted:

typedef int P();
typedef int Q();

Seems like ::P is a synonym for the type "a function that takes
no arguments and returns an int".
::Q is the same type synonym as ::P.


class X{
static P(Q);
static Q(P);

These two lines are syntax errors. Implicit return type is not
allowed (there is nothing between 'static' and the names).

};

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
.
User: "Bo Persson"

Title: Re: Name look up rules 24 Aug 2006 07:14:37 AM
"Victor Bazarov" <v.Abazarov@comAcast.net> skrev i meddelandet
news:IP2dneT7rJaTbHHZnZ2dnUVZ_r2dnZ2d@comcast.com...

puzzlecracker wrote:

example is taken from Evolution of C++.

I don't understand how the following will be interpreted:

typedef int P();
typedef int Q();



Seems like ::P is a synonym for the type "a function that takes
no arguments and returns an int".

::Q is the same type synonym as ::P.


class X{
static P(Q);
static Q(P);


These two lines are syntax errors. Implicit return type is not
allowed (there is nothing between 'static' and the names).

Only the second line is in error. On the first line, P is the type
from the typedef, so it declares Q as a static something (a function I
guess:-).
On the second line, the new X::Q hides the type Q so it doesn't work
here.
Writing the lines as
static P Q;
static Q P;
would have made it too obvious.
Bo Persson


};


V

.



  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER