help ASAP, why am I getting this error?

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 using namespace 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 


Weapon.cpp:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  1 #include "Weapon.h"
  2 #include<iostream>
  3 #include<string>
  4 using namespace std;
  5 
  6 Weapon:: Weapon(string weapon_1, int stamina, int hit)
  7   :hit_chance(hit), stamina_required(stamina), weapon(weapon_1)
  8 {
  9 }
 10 void Weapon::display(void)
 11 {
 12   cout << "hit chance=" << hit_chance  << endl;
 13   cout << "stamina required=" << stamina_required  << endl;
 14   cout << "weapon type is" << weapon << endl;
 15 }


assignment10.cpp:
1
2
3
4
5
6
7
8
9
10
  1 using namespace std;
  2 #include"Weapon.h"
  3       
  4 int main()
  5       
  6 {    
  7   Weapon w1 ("Lance", 13, 5);
  8   w1.display();
  9   return 0;
 10  }


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  
Your code looks fine to me.

Did you try rebuilding the project? Or maybe you are trying to compile an old version of it?

If that doesn't work, you could try making a new project and copy+pasting in your code...
Paste here the makefile.
Topic archived. No new replies allowed.