'defaultHealthCalc' is not a member of 'GameStuff'

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
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
#include "functionsForHealthCalc.h" needs to be in your main.cpp
Sorry - you need to have #include "functionsForHealthCalc.h" in your gameCharacter files.
Thanks! I just removed #include "GameCharacter.h" from functionsForHealthCalc.h
Last edited on
Topic archived. No new replies allowed.