On Feb 15, 5:50 pm, Adrian
> From the standard:-
> "11.4.3. A function first declared in a friend declaration has
> external linkage (3.5). Otherwise, the function retains
> its previous linkage (7.1.1)."
> Does this mean that if have a friend function in a class
> declaration in a header file I do not have to put the function
> prototype outside the class as well.
> I usually do:
> -----
> class foo
> {
> public:
> friend int foo_func();};
> int foo_func();
> ---------
> but is this the same:-
> --------------
> class foo
> {
> public:
> friend int foo_func();};
> -------------
It depends. Both declare exactly the same function, with
exactly the same linkage. But in the second case, the scope of
the declaration is the class, and it will only be found when the
compiler does a name lookup which includes the class (either
because it is from a class member function, or due to ADL).
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34