.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > SDK Programming discussions > Half-Life 2 SDK
Half-Life 2 SDK For developments focused around the Half-Life 2 engine Half-Life 2

Reply
 
Thread Tools
friend class?
Old
  (#1)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default friend class? - 12-12-2004

Does anybody know what this line means? I found CBotManager somewhere, as a friend class in the player.h

what is a friend class? I do not see a definition of it somewhere?

Code:
class CBasePlayer : public CBaseCombatCharacter
{
public:
 DECLARE_CLASS( CBasePlayer, CBaseCombatCharacter );
protected:
 // HACK FOR BOTS
 friend class CBotManager;
 static edict_t *s_PlayerEdict; // must be set before calling constructor


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Re: friend class?
Old
  (#2)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: friend class? - 12-12-2004

it's a class that when these two meet, they greet each other and have a drink together.

http://www.cplusplus.com/doc/tutorial/tut4-3.html

*edit*
btw, I'm at 13% downloading HL2



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."

Last edited by Pierre-Marie Baty; 12-12-2004 at 15:50..
  
Reply With Quote
Re: friend class?
Old
  (#3)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Re: friend class? - 12-12-2004

argh, So there you have it. Unbelievable that you have a FRIEND class so you can bypass protected/private data. Well that makes a lot of use then for protected/private stuff.

still odd that the code compiles without any definition of the friend class in the hl2 sdk. But then again i did not read the entire page and could have missed something. I don't feel well today.

I will burn some files for you PMB, and i hope to post it tomorrow.


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Re: friend class?
Old
  (#4)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: friend class? - 12-12-2004

"friend" is a standard C++ keyword, just like "const" or "virtual", that's why you don't need to define it...

Million thanks for the CD Stefan



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Re: friend class?
Old
  (#5)
botman
Super Moderator
 
Status: Offline
Posts: 280
Join Date: Jan 2004
Location: Plano, TX
Default Re: friend class? - 12-12-2004

The best way to remember this is...

"In C++, a friend is allowed to get at your private parts".

I assume it would have to be a REAL good friend.

botman
  
Reply With Quote
Re: friend class?
Old
  (#6)
Rick
Council Member
 
Rick's Avatar
 
Status: Offline
Posts: 690
Join Date: Dec 2003
Location: Holland
Default Re: friend class? - 12-12-2004

lol @ botman

I use "friends" for classes that are related, ie CBotManager and CBot.
  
Reply With Quote
Re: friend class?
Old
  (#7)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: friend class? - 12-12-2004

Ladies and gentlemen, please welcome the latest pearl in the greatest BU quotes thread, by the botman himself!



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com