This is the weirdest problem I have ever encountered, everything is correct and has been reviewed closely and the program still does not run. I tried this code on an online IDE as well (zybooks; my university's curriculum) and it worked perfectly fine on there.
What am I doing wrong?
main.cpp
#include <iostream>
#include "Character.h"
using namespace std;
int main(){
Character character("ekko", "black", 100, 100);
cout << character.getName();
return 0;
}
Character.cpp
#include "Character.h"
#include <iostream>
Character::Character(){
name = "Summoner";
race = "NONRACIAL";
level = 0;
health = 0;
}
Character::Character(string name, string race, int level, int heatlh ){
this->name = name;
this->race = race;
this->level = level;
this->health = health;
}
void Character::setName(string name){ this->name = name; }
void Character::setRace(string race){ this->race = race; }
void Character::setLevel(int level){ this->level = level; }
void Character::setHealth(int health){ this->health = health; }
string Character::getName(){ return name; }
string Character:: getRace(){ return race; }
int Character:: getLevel(){ return level; }
int Character:: getHealth(){ return health; }
Character.h
#include <iostream>
using namespace std;
#ifndef CHARACTER_H
#define CHARACTER_H
class Character{
private:
string name;
string race;
int level, health;
public:
Character();
Character(string name, string race, int level, int heatlh );
string getName();
string getRace();
int getLevel();
int getHealth();
void setName(string name);
void setRace(string race);
void setLevel(int level);
void setHealth(int health);
};
#endif
Error:
[Running] cd "c:\Users\diono\OneDrive\Desktop\COSC_1430_RPG_GAME\Character\" && g++ tempCodeRunnerFile.cpp -o tempCodeRunnerFile && "c:\Users\diono\OneDrive\Desktop\COSC_1430_RPG_GAME\Character\"tempCodeRunnerFile
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o): in function `main':
C:\temp\gcc\build-mingw-w64\mingw-w64-crt/../../src/mingw-w64-crt/crt/crt0_c.c:18: undefined reference to `WinMain'
collect2.exe: error: ld returned 1 exit status
[Done] exited with code=1 in 0.883 seconds