@giblit i get errors when running what you had, is Mangas way another way as well? people tell me and show me so many different ways of doing it it just confuses the hell out of me.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
#include <string>
#include <iostream>
class Player
{
public:
Player();
Player(int hp, std::string name);
~Player();
void start();
void output();
private:
int plr_health;
std::string plr_name;
};
Player::Player(): plr_name("player1")
{
}
Player::Player(int hp, std::string name) : plr_health( hp ),
plr_name( name )
{ }
Player::~Player()
{
}
void Player::output()
{
std::cout << "Name - " << plr_name << std::endl << "health - " << plr_health << std::endl;
}
|
obj\Debug\test.o||In function `ZN6PlayerC2Ev':|
C:\Users\Chay Hawk\Desktop\Modular testing\Test_Class.h|21|multiple definition of `Player::Player()'|
obj\Debug\Player_Source.o:C:\Users\Chay Hawk\Desktop\Modular testing\Test_Class.h|21|first defined here|
obj\Debug\test.o||In function `ZN6PlayerC2Ev':|
C:\Users\Chay Hawk\Desktop\Modular testing\Test_Class.h|21|multiple definition of `Player::Player()'|
obj\Debug\Player_Source.o:C:\Users\Chay Hawk\Desktop\Modular testing\Test_Class.h|21|first defined here|
obj\Debug\test.o||In function `ZN6PlayerC2EiSs':|
C:\Users\Chay Hawk\Desktop\Modular testing\Test_Class.h|25|multiple definition of `Player::Player(int, std::string)'|
obj\Debug\Player_Source.o:C:\Users\Chay Hawk\Desktop\Modular testing\Test_Class.h|25|first defined here|
obj\Debug\test.o||In function `ZN6PlayerC2EiSs':|
C:\Users\Chay Hawk\Desktop\Modular testing\Test_Class.h|25|multiple definition of `Player::Player(int, std::string)'|
obj\Debug\Player_Source.o:C:\Users\Chay Hawk\Desktop\Modular testing\Test_Class.h|25|first defined here|
obj\Debug\test.o||In function `ZN6PlayerD2Ev':|
C:\Users\Chay Hawk\Desktop\Modular testing\Test_Class.h|29|multiple definition of `Player::~Player()'|
obj\Debug\Player_Source.o:C:\Users\Chay Hawk\Desktop\Modular testing\Test_Class.h|29|first defined here|
obj\Debug\test.o||In function `ZN6PlayerD2Ev':|
C:\Users\Chay Hawk\Desktop\Modular testing\Test_Class.h|29|multiple definition of `Player::~Player()'|
obj\Debug\Player_Source.o:C:\Users\Chay Hawk\Desktop\Modular testing\Test_Class.h|29|first defined here|
obj\Debug\test.o||In function `ZN6Player6outputEv':|
C:\Users\Chay Hawk\Desktop\Modular testing\Test_Class.h|35|multiple definition of `Player::output()'|
obj\Debug\Player_Source.o:C:\Users\Chay Hawk\Desktop\Modular testing\Test_Class.h|35|first defined here|
||=== Build finished: 14 errors, 0 warnings (0 minutes, 1 seconds) ===|