• Create Account

### #Actualeppo

Posted 05 December 2012 - 06:50 AM

// Filename: playerclass.h.

//header file uses a pointer to a WeaponClass, so needs to know about its existence, but not its implementation
class WeaponClass;

class PlayerClass{

private:

WeaponClass* weapon;
};

-----

// Filename: playerclass.cpp

#include "weaponclass.h"


<quote>
talk BACK
</quote>

Best to avoid circular dependencies if you can. They tend to harm the modularity and readability of your code.

edit: too late

### #1eppo

Posted 05 December 2012 - 06:50 AM

// Filename: playerclass.h.

//header file uses a pointer to a WeaponClass, so needs to know about its existence, but not its implementation
class WeaponClass;

class PlayerClass{

private:

WeaponClass* weapon;
};

-----

// Filename: playerclass.cpp

#include "weaponclass.h"


<quote>
talk BACK
</quote>

Best to avoid circular dependencies if you can. They tend to harm the modularity and readability of your code.

PARTNERS