.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   Half-Life 2 SDK (http://forums.bots-united.com/forumdisplay.php?f=62)
-   -   friend class? (http://forums.bots-united.com/showthread.php?t=3186)

stefanhendriks 12-12-2004 13:01

friend class?
 
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


Pierre-Marie Baty 12-12-2004 15:49

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

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

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

stefanhendriks 12-12-2004 17:16

Re: friend class?
 
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.

Pierre-Marie Baty 12-12-2004 18:56

Re: friend class?
 
"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 :D

botman 12-12-2004 19:47

Re: friend class?
 
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

Rick 12-12-2004 20:11

Re: friend class?
 
lol @ botman :D

I use "friends" for classes that are related, ie CBotManager and CBot.

Pierre-Marie Baty 12-12-2004 22:11

Re: friend class?
 
Ladies and gentlemen, please welcome the latest pearl in the greatest BU quotes thread, by the botman himself! :D


All times are GMT +2. The time now is 16:10.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.