undefined reference to ...

0

Witam, mam .. dośc spory problem z funkcjami klasy Player.
Każda z funkcji ma zwracać wartość odpowiedniego pola prywatnego w klasie player.

#include "Player.h"
#include <string.h>
#include <iostream>
using std::string;
Player::Player()
{
    //ctor
}
int Player::getHP()
{
    return this->hp;
}
void Player::setHP(int a)
{

}
int Player::getSkill(int a)
{
    switch(a)
    {
    case 1:
        return this ->si;
        break;
    case 2:
        return this->zre;
        break;
    case 3:
        return this->in;
        break;
    case 4:
        return this->wyt;
        break;
    case 5:
        return this->sz;
        break;
    }
}
void Player::setSkill(int a, int b)
{
    switch(a)
    {
    case 1:
        this->si = b;
        break;
    case 2:
        this ->zre = b;
        break;
    case 3:
        this ->in = b;
        break;
    case 4:
        this->wyt=b;
        break;
    case 5:
        this->sz =b;
        break;
    }
}
int Player::getXp()
{
    return this->exp;
}
void Player::setXp(int a)
{
    this ->exp += (a);
}
int  Player::getMoney()
{
    return this->money;
}
void Player::setMoney(int a)
{
   this-> money +=(a);
}
string Player::getName()
{
    return this->name;
}
void Player::setName(string nick)
{
    name = nick;
}

 

Nie wiem czemu wywala mi te błędy :
user image
Jakies sugestie ?

#ifndef PLAYER_H
#define PLAYER_H
#include <string.h>
#include <iostream>

using std::string;
class Player
{
public:
    Player();
    int getHP();
    void setHP(int a);
    int getSkill(int a);
    void setSkill( int a, int b);
    int getXp();
    void setXp(int a);
    int getMoney();
    void setMoney(int a);
    string getName();
    void setName(string nick);
protected:
private:
    static int hp;
    static int hpMax;
    static long int exp;
    static int lvl;
    static int si;
    static int zre;
    static int in;
    static int wyt;
    static int sz;
    string name;
    long int money;


};

#endif // PLAYER_H
 
0

Ok. wywaliłem static z zmiennych i wszystko działa, dzięki za pomoc

0

http://msdn.microsoft.com/en-us/library/482s4fy9%28v=vs.80%29.aspx
Teoretycznie bedziesz mial szybszy dostep do zmiennej oznaczonej tym modyfikatorem. W praktyce, wszystko jest na lasce kompilatora.

1 użytkowników online, w tym zalogowanych: 0, gości: 1