Jump to content
  • Advertisement
Sign in to follow this  
DevlinHealy

Tutorial Problem

This topic is 2609 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

For starters I have triple-checked my work to ensure its exactly the same.


//Player.h = This header stores the players values, while Player.cpp gets, changes, or prints the values
class PLAYER
{
private:
char name[32];
int strength;
int intelligence;
int gold;
int experience;
int health;
int maxhealth;
int mana;
int maxmana;
int level;
public:
bool SetName(char* newname);
char* GetName();
void SetStrength(int newstr);
int GetStrength();
void SetIntelligence(int newint);
int GetIntelligence();
void SetGold(int newgood);
void AddGold(int amount);
int GetGold();
void SetExperience(int newexperience);
int AddExperience(int amount);
int GetExperience();
void SetHealth(int newhealth);
void AddHealth(int amount);
void LoseHealth(int amount);
int GetHealth();
void SetMaxHealth(int newmaxhealth);
int GetMaxHealth();
void SetMana(int newmana);
void AddMana(int amount);
void LoseMana(int amount);
int GetMana();
void SetMaxMana(int newmaxmana);
int GetMaxMana();

};



//Player.ccp
#include "Library.h"

int PLAYER::AddExperience(int amount)
{
SetExperience(experience + amount);
}
void PLAYER::AddGold(int amount)
{
SetGold(gold + amount);
}
void PLAYER::AddHealth(int amount)
{
SetHealth(health + amount);
}
void PLAYER::AddMana(int amount)
{
SetMana(mana + amount);
}
int PLAYER::GetExperience()
{
return experience;
}
int PLAYER::GetGold()
{
return gold;
}
int PLAYER::GetHealth()
{
return health;
}
int PLAYER::GetIntelligence()
{
return intelligence;
}
int PLAYER::GetMana()
{
return mana;
}
int PLAYER::GetMaxHealth()
{
return maxhealth;
}
int PLAYER::GetMaxMana()
{
return maxmana;
}
char PLAYER::GetName()
{
return name;
}
int PLAYER::GetStrength()
{
return strength;
}
void PLAYER::SetExperience(int newexperience)
{
experience = newexperience;

//check for level ups

}
void PLAYER::SetGold(int newgold)
{
gold = newgold;
}
void PLAYER::SetHealth(int newhealth)
{
health = newhealth;
}

void PLAYER::SetIntelligence(int newint)
{
intelligence = newint;
}
void PLAYER::SetMana(int newmana)
{
mana = newmana;
}
void PLAYER::SetMaxHealth(int newmaxhealth)
{
maxhealth= newmaxhealth;
}
void PLAYER::SetMaxMana(int newmaxmana)
{
maxmana = newmaxmana;
}
bool PLAYER::SetName(char* newname)
{
if(strlen(newname) ==0)
return false;

if(strlen(newname) > 32)
return false;

strcpy(name,newname);
return true;
}
void PLAYER::SetStrength(int newstr)
{
strength = newstr;
}


Both of these files are connected to "Library.h".

I get these errors:

1>c:\users\devlin\documents\visual studio 2010\projects\wrathlands\wrathlands\player.cpp(48): error C2556: 'char PLAYER::GetName(void)' : overloaded function differs only by return type from 'char *PLAYER::GetName(void)'
1> c:\users\devlin\documents\visual studio 2010\projects\wrathlands\wrathlands\player.h(16) : see declaration of 'PLAYER::GetName'
1>c:\users\devlin\documents\visual studio 2010\projects\wrathlands\wrathlands\player.cpp(48): error C2040: 'PLAYER::GetName' : 'char (void)' differs in levels of indirection from 'char *(void)'

This code is part of a project from : http://www.rdxgames....ands/index.html
It concludes part two of the tutorial.

He is using VS '03, I'm using the newest one, I understand they've added some more stringent requirements for syntax, which is probably why my code won't work but his did. These are the two errors I couldn't fix myself. Any help is appreciated.

Devlin

Share this post


Link to post
Share on other sites
Advertisement
You forgot the star at char PLAYER::GetName(), it should be char* PLAYER::GetName()

Share this post


Link to post
Share on other sites

You forgot the star at char PLAYER::GetName(), it should be char* PLAYER::GetName()


Those damn splats! So hard to noticetheyaren'tthere.....

Thanks Brah =)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!