ARGH! I Keep Getting An Error

This issue has been resolved! Thank you to everyone for helping!

Here's my code for the declarations and initialisations of some moves (Y'Know. Tackle, Tail Whip, that sort of thing).

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
  class _move                                                                     //Moves
{
      public:
             int number;                                                        //Move Index No. (used in learnsets)
             string name;
             ptype type;                                                        //Move type
             int basepower;                                                     //Base Power
             int accuracy;                                                      //Accuracy
             pmove efftype;                                                     //Move Effect Type
             int critratio;                                                     //0 if low, 1 if high
             int basepp;
      
             void setup(int a, string z, ptype b, int c, int d, pmove e, int g, int pp)
             {
                  number=a;     
                  name=z;                                               
                  type=b;                                                    
                  basepower=c;                                                 
                  accuracy=d;                                                  
                  efftype=e;                                                
                  critratio=g;
                  basepp=pp;
             }    
}move[166];  

move[0].setup(0, "Hop", WATER, 0, 0, Regular, 0, 0); 		/**/


The error I get is:


expected constructor, destructor, or type conversion before '.' token


The error appears for all setup(), from move[0] to move[165]

NOTE: I'm sure the error is some stupid oversight on my part.

EDIT: Just in case it helps, here are the enum declarations:

1
2
3
4
5
6
7
enum ptype {NORMAL, FIRE, FIGHTING, WATER, FLYING, GRASS, POISON, ELECTRIC, GROUND, PSYCHIC, ROCK, ICE, BUG, DRAGON, GHOST, DARK, STEEL};

enum pcolor {Red, Blue, Green, Yellow, Purple, Pink, Brown, Black, Grey, White};                                                      

enum pegggroup{Monster, Water1, Bug, Flying, Field, Fairy, Grass, HumanLike, Water3, Mineral, Amorphous, Water2, Ditto, Dragon, Undiscovered};

enum pmove {Regular, Status, Special, RegularStatus, MultipleHits, MultipleTurns, Stat};
Last edited on
I guess you need a default constructor.

Add _move() { } before void setup()

And you may want to change your class name to something else. _move is an ugly name for a class.
class Move { /* ... */ }; or
class PkmMove { /* ... */ };
etc...


Hmm.. on second thought, the problem is your enum. You need scope for your ptype and pmove argument

move[0].setup(0, "Hop", _move::WATER, 0, 0, _move::Regular, 0, 0);
Last edited on
Are you using C++11 with the <utility> header?
move is a template.

I renamed the array to xmove and had no issues after the removing the enums (not supplied).

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
#include <string> 
using namespace std;

class _move                                                 //Moves
{
      public:
             int number;                                     //Move Index No. (used in learnsets)
             string name;
             int basepower;                                //Base Power
             int accuracy;                                   //Accuracy
             int critratio;                                    //0 if low, 1 if high
             int basepp;
      
             void setup(int a, string z, int c, int d, int g, int pp)
             {   number=a;     
                  name=z;
                  basepower=c;                                                 
                  accuracy=d;                                                                                     
                  critratio=g;
                  basepp=pp;
             }    
} xmove[166];  

int main ()
{   xmove[0].setup(0, "Hop", 0, 0, 0, 0); 		/**/
    return 0;
}


BTW, identifiers beginning with _ are reserved for use by the compiler.
Thank you, tntxtnt and AbstractionAnon. I'll see if it works.

EDIT: Nope. See the post down there |
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . V
Last edited on
Removed ALL enums, added a constructor, renamed the class. STILL getting the error. WTH is happening?

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
class x_move                                                                     //Moves
{
      public:
             int number;                                                        //Move Index No. (used in learnsets)
             string name;
                                                                     //Move type
             int basepower;                                                     //Base Power
             int accuracy;                                                      //Accuracy
                                                                  //Move Effect Type
             int critratio;                                                     //0 if low, 1 if high
             int basepp;
      
             x_move()
             {
                  setup(0, "Hop", 0, 0, 0, 0);
             }
             
             void setup(int a, string z,int c, int d, int g, int pp)
             {
                  number=a;     
                  name=z;                                               
                                                               
                  basepower=c;                                                 
                  accuracy=d;                                                  
                                                            
                  critratio=g;
                  basepp=pp;
             }    
     
}xmove[166];  

xmove[0].setup(0, "Hop", 0, 0, 0, 0); 		/**/


IMPORTANT: I don't think I listed the second error correctly. Here the errors are:


expected constructor, destructor, or type conversion before '.' token
expected `,' or `;' before '.' token
Last edited on
Could you post the code where you are calling that method? Preferrably and entire program that gives you the error.
This declaration does not pull up any errors.

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
class _move                                                                     //Moves
{
      public:
             int number;                                                        //Move Index No. (used in learnsets)
             string name;
             ptype type;                                                        //Move type
             int basepower;                                                     //Base Power
             int accuracy;                                                      //Accuracy
             pmove efftype;                                                     //Move Effect Type
             int critratio;                                                     //0 if low, 1 if high
             int basepp;
      
             _move()
             {
                  setup(0, "Hop", WATER, 0, 0, Regular, 0, 0);
             }
             void setup(int a, string z, ptype b, int c, int d, pmove e, int g, int pp)
             {
                  number=a;     
                  name=z;                                               
                  type=b;                                                    
                  basepower=c;                                                 
                  accuracy=d;                                                  
                  efftype=e;                                                
                  critratio=g;
                  basepp=pp;
             }    
}move[166]; 



The moment I add the move[0].setup(), it gives me an error...

EDIT:

OMG, I'm such an idiot. The move[0].setup() should go within main(), shouldn't it?

EDIT (2):

Yup. Sorry for wasting your time, guys. And thanks a lot for all your help.

-Cheers!
Wild Jr
Last edited on
Topic archived. No new replies allowed.