Having a problem with friend class declarations (I always seem to ).
BC45 - DOS compile for a DOS Large model program
here's a snip of the relevant code (I can't include it all):
class ofLapTimerStr;
class ifLapTimerStr;
class LapTimer : public timer_base
{
friend class ofLapTimerStr;
friend class ifLapTimerStr;
protected:
Timer_t Best_Lap;
Timer_t Avg_Lap;
Timer_t Last_Lap;
Timer_t Prev_Lap;
Timer_t Total_LapTime;
...snip...
};
class ofLapTimerStr : public ofstream
{
...snip...
public:
ofLapTimerStr& operator<<(LapTimer &l);
};
class ifLapTimerStr : public ifstream
{
...snip...
public:
ifLapTimerStr& operator>>(LapTimer &l);
};
ofLapTimerStr& ofLapTimerStr::operator<<(LapTimer &l)
{
(ofstream &)*this << l.MarkCount << l.Last_Lap << l.Prev_Lap <<
l.Total_LapTime << l.Avg_Lap << l.Best_Lap;
return *this;
}
[ifLapTimerStr is the compliment of the above]
When compiling, I get the errors
MAKE Version 3.7 Copyright (c) 1987, 1994 Borland International
Error lapwin.cpp 352: 'LapTimer::Last_Lap' is not accessible in
function ofLapTimerStr::operator <<(LapTimer &)
Error lapwin.cpp 352: 'LapTimer::Prev_Lap' is not accessible in function
ofLapTimerStr::operator <<(LapTimer &)
Error lapwin.cpp 352: 'LapTimer::Total_LapTime' is not accessible
in function ofLapTimerStr::operator <<(LapTimer &)
Error lapwin.cpp 352: 'LapTimer::Avg_Lap' is not accessible in
function ofLapTimerStr::operator <<(LapTimer &)
Error lapwin.cpp 352: 'LapTimer::Best_Lap' is not accessible in function
ofLapTimerStr::operator <<(LapTimer &)
...etc... same errors for ifLapTimerStr...
My understanding was that "friend class ..." made ALL members irregardless of
protection "accessible" to the friend class. I've had this problem before,
nd
the only solution was to make the necessary members public; but I don't
really
want them public.
friend functions work perfectly, but trying to make a whole class a friend
doesn't. :(
Any solutions? (besides deriving the *Str classes from LapTimer, I've
considered it but it adds some additional headaches I'd rather not deal with
at present)
# Herbert Bushong harchon@centuryinter.net [TEAM OS/2]
- Blackbeard's BBS Intelec: 239:600/0
+ Fido: 1:19/19 http://www.intelec.com/software/
---
RM 1.31 2508 URA Redneck if you use a bed sheet as a sofa cover
---------------
* Origin: Blackbeard's BBS - Ville Platte, LA - 318-468-3385 (1:19/19)
|