Im having some trouble working these 3 files, When i go to compile the files they compile but i run the program and it crashes. When i save Damage.h as a cpp it gives linker win16 error i did it just to see if would create errors well finding out ways to fix it.
Im not sure wat is rong on the internet it said for a different series of code to add a empty main i did but that just makes multiple definitions. My goal is to fix this so it runs :P. I couldnt find any syntax errors.
Damage Function. << Damage.h
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int Damage(int param1, int param2){
srand(time(NULL));
int Maxdamage = param2;
int Mindamage = param1;
int random =rand() % Maxdamage + Mindamage ;
return(random);
}
Main function. << Main.cpp
Code:
#include<iostream>
#include "Weapon.h"
#include "Damage.h"
int main(){
weapon sword1;
sword1.maxdamage = 12;
sword1.mindamage = 1;
int damage = Damage(sword1.maxdamage,sword1.mindamage);
std::cout << damage;
system("PAUSE");
return 0;
}
Weapon class. << Weapon.h
Code:
#ifndef WEAPON_H
#define WEAPON_H
class weapon
{
public:
int maxdamage;
int mindamage;
};
#endif
Nvm i ____think______ i fixed it