Compilation error

Error Messages over some little mistake
[26 C:\Dev-Cpp\Untitled7.cpp `string' does not name a type code]
27 C:\Dev-Cpp\Untitled7.cpp variable or field `SetType' declared void
27 C:\Dev-Cpp\Untitled7.cpp expected `;' before '(' token
29 C:\Dev-Cpp\Untitled7.cpp expected `;' before "int"
38 C:\Dev-Cpp\Untitled7.cpp `string' does not name a type
39 C:\Dev-Cpp\Untitled7.cpp variable or field `SetAdvantage' declared void
39 C:\Dev-Cpp\Untitled7.cpp expected `;' before '(' token
41 C:\Dev-Cpp\Untitled7.cpp expected `;' before "string"
41 C:\Dev-Cpp\Untitled7.cpp `string' does not name a type
42 C:\Dev-Cpp\Untitled7.cpp variable or field `SetDisadvantage' declared void
42 C:\Dev-Cpp\Untitled7.cpp expected `;' before '(' token
44 C:\Dev-Cpp\Untitled7.cpp expected `;' before "string"
44 C:\Dev-Cpp\Untitled7.cpp `string' does not name a type
45 C:\Dev-Cpp\Untitled7.cpp variable or field `SetMonsterName' declared void
45 C:\Dev-Cpp\Untitled7.cpp expected `;' before '(' token
47 C:\Dev-Cpp\Untitled7.cpp expected `;' before "private"
48 C:\Dev-Cpp\Untitled7.cpp `string' does not name a type
52 C:\Dev-Cpp\Untitled7.cpp `string' does not name a type
53 C:\Dev-Cpp\Untitled7.cpp `string' does not name a type
54 C:\Dev-Cpp\Untitled7.cpp `string' does not name a type
C:\Dev-Cpp\Untitled7.cpp In constructor `Monster::Monster()':
10 C:\Dev-Cpp\Untitled7.cpp `cout' undeclared (first use this function)
(Each undeclared identifier is reported only once for each function it appears in.)
C:\Dev-Cpp\Untitled7.cpp In destructor `Monster::~Monster()':
11 C:\Dev-Cpp\Untitled7.cpp `cout' undeclared (first use this function)
C:\Dev-Cpp\Untitled7.cpp In member function `void Monster::DisplayStats()':
15 C:\Dev-Cpp\Untitled7.cpp `cout' undeclared (first use this function)
16 C:\Dev-Cpp\Untitled7.cpp `Type' undeclared (first use this function)
21 C:\Dev-Cpp\Untitled7.cpp `Advantage' undeclared (first use this function)
C:\Dev-Cpp\Untitled7.cpp In function `int main(int, char**)':
59 C:\Dev-Cpp\Untitled7.cpp 'class Monster' has no member named 'SetType'
63 C:\Dev-Cpp\Untitled7.cpp 'class Monster' has no member named 'SetAdvantage'
64 C:\Dev-Cpp\Untitled7.cpp 'class Monster' has no member named 'SetDisadvantage'
65 C:\Dev-Cpp\Untitled7.cpp 'class Monster' has no member named 'SetMonsterName'
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <iostream>
#include <ctime>
#include <string>
#include <sstream>
#include <cstdlib>
class Monster
{
      public:      
      // constructor
      Monster() { cout << "\n\tBuilding a Monster"; }
      ~Monster() { cout << "\n\tDestroying a Monster"; }
      //Memeber Methods      
      void DisplayStats()
      {
           cout << "\n\n\t--------Monster Stats--------";
           cout << "\n\tYou sent out a " << Type << " type.";
           cout << "\n\tIts stats are";
           cout << "\n\tAttack" << Attack;
           cout << "\n\tDefense" << Defense;
           cout << "\n\tHealth" << Health;
           cout << "\n\tAdvantage" << Advantage;
           cout << "\n\tDisadvantage" << Health;
           cout << "\n\t-------------------------------";
      } 
      //Accessor Methods
      string GetType() { return Type; }
      void SetType(string x) { Type = x; }
      
      int GetAttack() { return Attack; }
      void SetAttack(int x) { Attack = x; }
      
      int GetDefense() { return Defense; }
      void SetDefense(int x) { Defense = x; }
      
      int GetHealth() { return Health; }
      void SetHealth(int x) { Health = x; }
      
      string GetAdvantage() { return Advantage; }
      void SetAdvantage(string x) { Advantage = x; }
      
      string GetDisadvantage() { return Disadvantage; }
      void SetDisadvantage(string x) { Disadvantage = x; }
      
      string GetMonsterName() { return MonsterName; }
      void SetMonsterName(string x) { MonsterName = x; }
      
      private:
      string Type;
      int Attack;
      int Defense;
      int Health;
      string Advantage;
      string Disadvantage;
      string MonsterName;
}; 
int main(int argc, char *argv[])
{
Monster * YourFireType = new Monster;
YourFireType->SetType("Fire");
YourFireType->SetAttack(8);
YourFireType->SetDefense(1);
YourFireType->SetHealth(40);
YourFireType->SetAdvantage("Nature");
YourFireType->SetDisadvantage("Water");
YourFireType->SetMonsterName("YourFireType");
YourFireType->DisplayStats();
system("PAUSE");
return 0;
};
Last edited on
You are not using the namespace std;
Forgot right?

Aceix.
Thanks, i have been going over the code for an hour (in a new file) trying to find the solution when i knew everything was written right, so i could implement it in the code, and turns out i forgot that in the process
Topic archived. No new replies allowed.