Functions returning odd values

I've been looking through classes and been trying to organize material as best I can, so I have started setting up values in functions contained in classes. Whenever the value of damage is returned I get -858993460. Any ideas?

Header file the class is stored in:
class swords
{
public:
void setDamage(int strengthEffect, int sharpnessEffect)
{
int damage = (strengthEffect + sharpnessEffect)*sharpnessEffect;
};
int getDamage()
{
return damage;
}
private:
int damage;

};

main function from cpp file:

#include <iostream>
#include <string>
#include "Weapons.h"


int main()
{
int level = 1;
int money;
int strength = 5;
std::string name;

swords TrainingSword;
TrainingSword.setDamage(strength, 10);
TrainingSword.getDamage();
std::cout << TrainingSword.getDamage() << std::endl;
std::cin >> money;
return 0;
}
In the swords class, void setDamage(int strengthEffect, int sharpnessEffect)

 
int damage = (strengthEffect + sharpnessEffect) * sharpnessEffect

should be

 
damage = (strengthEffect + sharpnessEffect) * sharpnessEffect


since adding int in front means you're creating another variable and not assigning to one.
Last edited on
Thank you so much, solved the problem.
Topic archived. No new replies allowed.