Archived

This topic is now archived and is closed to further replies.

class instance problem

This topic is 5320 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

what does the error "left side must be a structure in function DoTestMainChar()" mean?
    

void DoTestMainChar(void)
{
        int damage = 2;
	int heal = 3;
	
	clrscr();

	Character hero();
  
        hero.DoTakeDamage(damage);
	hero.DoShowStats();
	hero.DoGetHealed(heal);
	hero.DoShowStats();
	
	getch();

}

    
[edited by - mrtie_dye on May 26, 2003 7:25:49 PM]

Share this post


Link to post
Share on other sites
Here is the rest of the code, in case it helps...


    

class humanoid
{
protected:
int hitpoints;
int armorclass;
int thaco;
int race;

public:
virtual void DoTakeDamage(int damage);
virtual void DoGetHealed(int heal);
virtual void DoShowStats() = 0;

humanoid();
};

void humanoid::DoTakeDamage(int damage)
{
hitpoints = hitpoints - damage;

}

void humanoid::DoGetHealed(int heal)
{
hitpoints = hitpoints + heal;

}

humanoid::humanoid()
{

}

class Character : public humanoid
{
protected:
int strength;
int dexterity;
int intelligence;
int wisdom;
int charisma;
int constitution;
int expirence;
int level;
int profession;
public:
int DoReturnHitProb();
int DoReturnDmgAdj();
int DoReturnDefenseAdj();
void DoShowStats();

Character();
};

Character::Character() : humanoid()
{

}

int Character::DoReturnHitProb()
{
int hitprob;

if (strength == 3)
{
hitprob = -3;
}
if (strength >3 && strength < 6)
{
hitprob = -2;
}
if (strength > 5 && strength < 8)
{
hitprob = -1;
}
if (strength > 7 && strength < 17)
{
hitprob = 0;
}
if (strength == 17)
{
hitprob = 1;
}
if (strength == 18)
{
hitprob = 2;
}

return hitprob;
}

int Character::DoReturnDmgAdj()
{
int dmgadj;

if (strength < 6)
dmgadj = -1;

if (strength > 5 && strength < 16)
dmgadj = 0;

if (strength > 15 && strength < 18)
dmgadj = 1;

if (strength == 18)
dmgadj = 2;

return dmgadj;
}

int Character::DoReturnDefenseAdj()
{
int defenseadj;

if (dexterity == 3)
defenseadj = 4;

if (dexterity == 4)
defenseadj = 3;

if (dexterity == 5)
defenseadj = 2;

if (dexterity == 6)
defenseadj =1;

if (dexterity > 6 && dexterity < 15)
defenseadj = 0;

if (dexterity == 15)
defenseadj = -1;

if (dexterity == 16)
defenseadj = -2;

if (dexterity == 17)
defenseadj = -3;

if (dexterity == 18)
defenseadj = -4;

return defenseadj;
}

void Character::DoShowStats()
{
cout <<"strength = : " << strength << endl;
cout <<"dexterity = : " << dexterity << endl;
cout <<"inteligence = : " << intelligence << endl;
cout <<"wisdom = : " << wisdom << endl;
cout <<"charisma = : " << charisma << endl;
cout <<"constitution = : " << constitution << endl;
cout <<"expirence = : " << expirence << endl;
cout <<"level = : " << level << endl;
cout <<"class = : " << profession << endl;
cout <<"hitpoints = : " << hitpoints << endl;
cout <<"armorclass = : " << armorclass << endl;
cout <<"thaco = : " << thaco << endl;
cout <<"race = : " << race << endl;
}



[edited by - mrtie_dye on May 26, 2003 8:07:06 PM]

Share this post


Link to post
Share on other sites