In this .cpp i have an error saying member function cannot be redeclared. I dont know what it needs to get rid of the error obviously it needs a declaration somewhere but where?

#include <iostream>
#include <ctime>
using namespace std;


Monster::Monster(std::string Name, int health, int hitPoints,
		    int miss, int damage,const std::string& weaponName)

{
	Name = Name;
	hitPoints = hitPoints;
	Weapon weapon;
	miss = miss;
	damage = damage;
	weapon.Name = weaponName;



}

bool Monster::Death()
{
	return hitPoints <= 0;
}
std::string Monster::getName()
{
	return Name;
}


void Monster::attack(Player& player)
{
	{
    srand((unsigned)time(0));
    int random_integer;
    for(int index=0; index<1; index++){
    random_integer = (rand()%2)+1;
    cout << random_integer << endl;
    }

	cout << "A " << Name << " attacks you "
		 <<"with a " << weapon.Name << endl;

	int damage = weapon.weaponHitPoints;
	if(random_integer = 1)
	{
		Player.takeDamage;
		cout << "Your Health is minus: " << damage;
	}
	else if( random_integer = 2)
	{
		cout<< "You missed";
	}

	
	void Monster::takeDamage(int damage)
{
	HitPoints -= damage;
}

void Monster::displayHitPoints()
{
	cout << Name << "'s hitpoints = " << HitPoints << endl;
}


		
}

Recommended Answers

All 2 Replies

Which member function is the compiler complaining about?

You've screwed up your brackets and have some functions being defined within other functions.

Fix brackets.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.