Game project

I'm doing a project thats a jousting game between knights, I'm doing all my class (3) and everything all in one file, is that okay?
I also am getting an error...
Heres my code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
  1 #include<iostream>
  2 #include<string>
  3 using namespace std;
  4 
  5 class Weapon{
  6   private:
  7     int hit_chance;
  8     int stamina_required;
  9     string weapon_type;
 10  public:
 11     void display (void);
 12     Weapon(string type, int sr, int hc);
 13     int get_stamina_required(void);
 14     bool did_you_hit(void);
 15 }
 16 Weapon:: Weapon(string type, int sr, int hc)
 17   :hit_chance(hc), stamina_required(sr), weapon_type(type)
 18 {
 19 }
 20 
 21 void Weapon::display(void)
 22 {
 23   cout<< "hit chance=" << hit_chance << endl;
 24   cout<< "stamina required=" << stamina_required << endl;
 25   cout<< "weapon type is" << weapon_type<< endl;
 26 
 27 }


and here's my error:
1
2
3
projecttwo.cpp:5: error: new types may not be defined in a return type
projecttwo.cpp:5: note: (perhaps a semicolon is missing after the definition of 'Weapon')
projecttwo.cpp:16: error: return type specification for constructor invalid
closed account (o1vk4iN6)
This isn't Java. You are required to place a semicolon after a class declaration.

1
2
3
4
class Weapon
{

};
Last edited on
@xerzi:
When I did that I got this error:
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


So I thought it was wrong! Guess not but it's still not compiling...
I don't see a main() function anywhere in this code. If this is just a class file that's meant to be part of a bigger project, don't try to link/run it by itself.
closed account (o1vk4iN6)
So you have 2 errors, you solved one and now another is showing.
Topic archived. No new replies allowed.