I'm doing a part to a project where I'm making a weapon class and a test program. The weapon class has to have three private data members: two integers (hit_chance and stamina_required) and a string for the weapon type. There is suppossed to be two public member functions: a display function which prints out the private data members and a constructor (which takes 3 arguments to initialize the private data). My teacher wants us to split the Weapon class into Weapon.h and Weapon.cpp and to put the main() function in another file named assignment10.cpp
Then I'm writing a makefile to build the program.
Heres what I have for the Weapon.h:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
1 #ifndef WEAPON_H
2 #define WEAPON_H
3 #include<string>
4 usingnamespace std;
5
6
7 class Weapon {
8 private:
9 int hit_chance;
10 int stamina_required;
11 string weapon;
12
13
14 public:
15 void display(void);
16 Weapon(string weapon_1, int hit, int stamina);
17
18 };
19 #endif
I'm getting these two errors but I can't figure out why! Please help!
1 2 3
/usr/lib64/gcc/x86_64-slackware-linux/4.4.4/../../../../lib64/crt1.o: In function `_start':
/glibc-tmp-4211a76efa4c5de6d46269f47808acd6/glibc-2.11.1/csu/../sysdeps/x86_64/elf/start.S:109: undefined reference to `main'
collect2: ld returned 1 exit status
1 2 3 4
/tmp/cc2w47FN.o: In function `main':
assignment10.cpp:(.text+0x45): undefined reference to `Weapon::Weapon(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, int)'
assignment10.cpp:(.text+0x84): undefined reference to `Weapon::display()'
collect2: ld returned 1 exit status