Apr 26, 2014 at 1:05pm UTC
Hello!
Why I received this message:
GameCharacter.h:13: error: 'defaultHealthCalc' is not a member of 'GameStuff'
explicit GameCharacter( std::string name, HealthCalcFunc hcf = GameStuff::defaultHealthCalc )
GameCharacter.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#ifndef GAMECHARACTER_H
#define GAMECHARACTER_H
#include <string>
#include "functionsForHealthCalc.h"
namespace GameStuff {
class GameCharacter {
public :
typedef int (*HealthCalcFunc)(const GameCharacter&);
explicit GameCharacter( std::string name, HealthCalcFunc hcf = GameStuff::defaultHealthCalc )
{
}
};
}
#endif // GAMECHARACTER_H
functionsForHealthCalc.h
1 2 3 4 5 6 7 8 9 10 11 12 13
#ifndef FUNCTIONS_FOR_HEALTHCALC_H
#define FUNCTIONS_FOR_HEALTHCALC_H
#include "GameCharacter.h"
namespace GameStuff {
class GameCharacter;
int defaultHealthCalc( const GameCharacter& gc );
}
#endif // FUNCTIONS_FOR_HEALTHCALC_H
functionsForHealthCalc.cpp
1 2 3 4 5 6 7 8
#include "functionsForHealthCalc.h"
namespace GameStuff {
int defaultHealthCalc( const GameCharacter& gc ) {
return 1;
}
}
Last edited on Apr 26, 2014 at 6:35pm UTC
Apr 26, 2014 at 6:12pm UTC
main.cpp
1 2 3 4 5 6
#include <iostream>
int main() {
return 0;
}
There are all my files. Please, help me!
Last edited on Apr 26, 2014 at 6:18pm UTC
Apr 26, 2014 at 9:27pm UTC
#include "functionsForHealthCalc.h" needs to be in your main.cpp
Apr 26, 2014 at 9:29pm UTC
Sorry - you need to have #include "functionsForHealthCalc.h" in your gameCharacter files.
Apr 27, 2014 at 4:01am UTC
Thanks! I just removed #include "GameCharacter.h" from functionsForHealthCalc.h
Last edited on Apr 27, 2014 at 4:02am UTC