Compiler Error: "multiple types in one declaration"

Started by
1 comment, last by Atash 18 years, 4 months ago
I am sorry for consistently coming here at every little problem, but I just couldn't find this one after scanning the entire code about ten times over. I have an error coming from line number 39, which is the end of the block for my declaration of the 'Paddle' class: "multiple types in one declaration". I have also gotten the same error on and off for the SAME code on the line describing my inline getY function. When the error code comes up for getY, it doesn't come up for the end of the class block. Any help?

/*This is going to be pong. Tetris comes later*/
#include <stdio.h>
#include <stdlib.h>
#include <SDL/SDL.h>

const int MAX_PLAYERS = 4;
const int DIM = 600;
SDL_Surface *screen = SDL_SetVideoMode(DIM, DIM, 32, SDL_HWSURFACE|SDL_DOUBLEBUF);


class Ball
{
      int posX;
      int posY;
      public:
}

class Paddle
{
      private:
              int posX;
              int posY;
              //SDLKey keycheck[];
              SDL_Surface *image;
              int type;
              bool touchingR;
              bool touchingL;
              //the touch goes in a clockwise direction. R is the paddles right. L is the left;
      public:
             static int x[];
             static int y[];
             Paddle(int playNumber);
             ~Paddle();
             int getX() {return posX;}
             int getY() {return posY;}
             void setX(int x) {posX = x;}
             void setY(int y) {posY = y;}
             void drawANDcheck();
};

Paddle::Paddle(int playNumber)
{
                switch(playNumber)
                {
                       case 1:
                            posX = 10;
                            posY = DIM/2 - 50;
                            image = SDL_DisplayFormat(SDL_LoadBMP("player1.bmp"));
                            //keycheck[0] = SDLK_q;
                            //keycheck[1] = SDLK_a;
                            type = 1;
                            touchingL = false;
                            touchingR = false;
                            break;
                       case 2:
                            posX = DIM - 20;
                            posY = DIM/2 - 50;
                            image = SDL_DisplayFormat(SDL_LoadBMP("player1.bmp"));
                            //keycheck[0] = SDLK_UP;
                            //keycheck[1] = SDLK_DOWN;
                            type = 2;
                            touchingL = false;
                            touchingR = false;
                            break;
                       case 3:
                            posX = DIM/2 - 50;
                            posY = DIM - 20;
                            image = SDL_DisplayFormat(SDL_LoadBMP("player3.bmp"));
                            //keycheck[0] = SDLK_x;
                            //keycheck[1] = SDLK_c;
                            type = 3;
                            touchingL = false;
                            touchingR = false;
                            break;
                       case 4:
                            posX = DIM/2 - 50;
                            posY = 10;
                            image = SDL_DisplayFormat(SDL_LoadBMP("player3.bmp"));
                            //keycheck[0] = SDLK_h;
                            //keycheck[1] = SDLK_j;
                            type = 4;
                            touchingL = false;
                            touchingR = false;
                            break;
                       //type: 1<   2>  3v    4^
                }
}

Paddle::~Paddle()
{
}

void Paddle::drawANDcheck()
{
     SDL_Event event;
     SDL_Rect *dst;
     
     if(type == 1 || type == 2)
     {
             dst->w = 10;
             dst->h = 100;
     }
     if(type == 3 || type == 4)
     {
             dst->w = 100;
             dst->h = 10;
     }
     
     dst->x = posX;
     dst->y = posY;
     SDL_BlitSurface(image, NULL, screen, dst);
     //checking is seperated for ease of reading
     switch(type)
     {
             case 1:
                  if(posY == 0)
                  {
                  touchingL = true;
                  }
                  if(posY == DIM)
                  {
                  touchingR = true;
                  }
                  while(SDL_PollEvent(&event))
                  {
                  switch(event.key.keysym.sym)
                  {
                                              case SDLK_q:
                                                   posY +=4;
                                              case SDLK_a:
                                                   posY -=4;
                                              
                  }
                  }
             case 2:
                  if(posY == 0)
                  {
                  touchingR = true;
                  }
                  if(posY == DIM)
                  {
                  touchingL = true;
                  }
                  while(SDL_PollEvent(&event))
                  {
                  switch(event.key.keysym.sym)
                  {
                                              case SDLK_UP:
                                                   posY +=4;
                                              case SDLK_DOWN:
                                                   posY -=4;
                                              
                  }
                  }
             case 3:
                  if(posX == 0)
                  {
                  touchingL = true;
                  }
                  if(posX == DIM)
                  {
                  touchingR = true;
                  }
                  while(SDL_PollEvent(&event))
                  {
                  switch(event.key.keysym.sym)
                  {
                  case SDLK_x:
                  posX -=4;
                  case SDLK_c:
                  posX +=4;
                                              
                  }
                  }
             case 4:
                  if(posX == 0)
                  {
                   touchingR = true;
                  }
                   if(posX == DIM)
                  {
                   touchingL = true;
                  }
                  
                  while(SDL_PollEvent(&event))
                  {
                  switch(event.key.keysym.sym)
                  {
                                              case SDLK_h:
                                                   posX -=4;
                                              case SDLK_j:
                                                   posX +=4;
                                              
                  }
                  }
     }
}


int main(int argc, char *argv[])
{
    bool running = true;
    if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) == -1)
    {
                                return 0;
    }
atexit (SDL_Quit);

//game-code starts here :)

while(running)
{
              bool start_screen = true;
              bool playing = false;
              SDL_Delay(1);
              SDL_Flip(screen);
              
              while(start_screen)
              {
                                 SDL_Event event;
                                 while(SDL_PollEvent(&event))
                                 {
                                                            
                                 }
                                 Paddle a = Paddle(1);
                                 Paddle b = Paddle(2);
                                 
                                 a.drawANDcheck();
                                 b.drawANDcheck();
                                 
              }
}


return 0;
}

*After Argument*P1: What was it about?P2: Something involving a chair, a cat, and a rubber ducky...
Advertisement
You have to put a ";" after a class declaration.

class Ball {
public:
Thippity-Bleah();
private:
int penguin;
};

If you don't put that ; at the end of the declaration block then it will think you're doing something really strange with the Ball class and the Paddle class.

EDIT: Ahh, you have a ; after your Paddle class declaration so I doubt any explanation was necessary - just a typing mistake. Those can be surprisingly nasty. :)
It only takes one mistake to wake up dead the next morning.
Meh...

It could be the actual compiler having an error... I'ma check the bloodshed.net site...

Actually...

Wow. Thanks, you just reminded me that I hadn't put a semi-colon right after the ball class... Err.

I forgot to put the semi-colon for the 'ball' class...
...
...
...
I thought I commented that out...

THANKS!!! >_<
*After Argument*P1: What was it about?P2: Something involving a chair, a cat, and a rubber ducky...

This topic is closed to new replies.

Advertisement