From -9001478295997719722
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,2b0387157d35b1a9
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1995-01-20 14:27:42 PST
Newsgroups: comp.std.c++
From: andys@thone.demon.co.uk (Andy Sawyer)
Path: nntp.gmd.de!newsserver.jvnc.net!nntpserver.pppl.gov!princeton!gw1.att.com!fnnews.fnal.gov!mp.cs.niu.edu!vixen.cso.uiuc.edu!howland.reston.ans.net!news.sprintlink.net!pipex!peernews.demon.co.uk!thone.demon.co.uk!andys
Subject: Re: Need advice on developing classes
References: <D2ByGp.E4A@seas.ucla.edu> <1995Jan13.155558.4483@rcmcon.com>
Organization: The United Federation Of Planets
Reply-To: andys@thone.demon.co.uk
X-Newsreader: Demon Internet Simple News v1.29
Lines: 58
X-Posting-Host: thone.demon.co.uk
Date: Fri, 20 Jan 1995 22:27:42 +0000
Message-ID: <790640862snz@thone.demon.co.uk>
Sender: usenet@demon.co.uk

In article <1995Jan13.155558.4483@rcmcon.com>
           rmartin@rcmcon.com "Robert Martin" writes:

[snip]
> 
> Friendship cannot be stolen, only given. Its use is
> to expose privates to a priviledged few, so that those privates do not
> have to exposed to the world.
> 
how about:

"x.h"
class X {
   static int si_XVal;
   friend void TheFriend();
};

"file1.cpp"
static void TheFriend();
#include "x.h"

static void TheFriend()
{
 si_XVal = 0;
}

"file2.cpp"
static void TheFriend();
#include "x.h"

static void TheFriend()
{
 si_XVal = 1;
}

 Someone has stolen the friendship there!

An even more worrying case (depending more on your linker than anything else)
is that if TheFriend lies in a external library, the following is possible:

"example.cpp"
#include "x.h"

void TheFriend()
{
  // Do what ya want in here!
}

May linkers would not attempt to resolve TheFriend in external libraries in
this case....

Regards,
 Andy
-- 
* Andy Sawyer ** e-mail:andys@thone.demon.co.uk ** Compu$erve:100432,1713 **
 The opinions expressed above are my own, but you are granted the right to
 use and freely distribute them. I accept no responsibility for any injury,
 harm or damage arising from their use.                --   The Management.


