Compiler/Class bug?

This is a discussion on Compiler/Class bug? within the C++ Programming forums, part of the General Programming Boards category; Ok, I added in another class to keep track of tile steps (sounds useless doesnt it ?:P) Anyways, when I ...

  1. #1
    60% Braindead
    Join Date
    Dec 2005
    Posts
    379

    Compiler/Class bug?

    Ok, I added in another class to keep track of tile steps (sounds useless doesnt it ?:P) Anyways, when I tried to add it in, it gave me a weird error...
    Code:
    Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
    C:\MazeOfPain.cpp:
    Error E2176 C:\KeeperClass.h 3: Too many types in declaration
    *** 1 errors in Compile ***
    It seems my compiler always gives me a new error thats totaly weird -,-.

    Ok, the weird thing is, I have only declared threee classes. Keeper, Enemy, WeakWall.

    The codes for each (Starting from WeakWall and ending with Enemy.)

    Code:
    #include <windows.h>
    #include <iostream>
    #include <string.h>
    #include <conio.h>
    #include <fstream>
    using namespace std;
    
    class WeakWall {
     private:
      SHORT Strength;
      SHORT SteppedOn;
      SHORT x;
      SHORT y;
     public:
      WeakWall() {Strength=1; SteppedOn=0; x=0; y=0;}
      WeakWall(SHORT str, SHORT Step, SHORT x_pos, SHORT y_pos) {Strength=str; SteppedOn=Step; x=x_pos; y=y_pos;}
    
      SHORT GetX() {return x;}
      SHORT GetY() {return y;}
      SHORT GetStr() {return Strength;}
      SHORT GetWStatus() {return SteppedOn;}
      void Reset() {Strength=1; SteppedOn=0; x=0; y=0;}
    }
    Code:
    #include "WeakWall.h"
    
    class Keeper {
     private:
      SHORT zzx[5];
    
     public:
      Keeper() {zzx[0] = 0; zzx[1] = 0; zzx[2] = 0; zzx[3] = 0; zzx[4] = 0;}
      Keeper(SHORT z, SHORT zz, SHORT zzz, SHORT zzzz, SHORT b) {zzx[0] = z; zzx[1] = zz; zzx[2] = zzz; zzx[3] = zzzz; zzx[4] = b;}
      
      void Check(SHORT x) {zzx[x] = 1;}
      void Uncheck(SHORT x) {zzx[x] = 0;}
      void UncheckAll() {zzx[0] = 0; zzx[1] = 0; zzx[2] = 0; zzx[3] = 0; zzx[4] = 0;}
     
      SHORT IsChecked(SHORT x);
    };
    
    SHORT Keeper::IsChecked(SHORT x) {
     if(zzx[x] == 1)
      return 1;
     
     return 0;
    }
    Code:
    #include "KeeperClass.h"
    
    #define Enemy1 '@'
    #define Enemy2 '&' 
    #define Enemy3 '$'
    #define Enemy4 '%'
    
    #define No 10 //Movement Definitions.
    #define Ea 15
    #define So 20
    #define We 25
    
    HANDLE hOt = GetStdHandle(STD_OUTPUT_HANDLE);
    HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE);
    
    class Enemy {
     private:
    
     char Ent;
     int ex_pos;
     int ey_pos;
     int tag;
     int mproc;
     SHORT alive;
    
     public:
    
     Enemy() {Ent=0;ex_pos=0;ey_pos=0;tag=0;mproc=0;alive=0;}
    
     Enemy(char t, int ex, int ey, int etag, int moving, SHORT live) {t=Ent;ex=ex_pos;ey=ey_pos;etag=tag;moving=mproc;live=alive;}
    
     char GetType() {return Ent;}
     int GetX() {return ex_pos;}
     int GetY() {return ey_pos;}
     int GetTag() {return tag;}
     int GetMovement() {return mproc;} //40
     SHORT IsAlive() {return alive;}
    
     void SetType(char c) {Ent=c;}
     void SetX(int x) {ex_pos=x;}
     void SetY(int y) {ey_pos=y;}
     void SetTag(int Tag) {tag=Tag;}
     void SetMovement(int Move) {mproc=Move;}
     void SetLive(int live) {alive=live;}
    };
    My compiler gives me no other errors (thankfully -,-) but It just seems to not like that I declared three classes. Though I dont know why it would mind that as I'm sure some people declare many more.

    So, what is this error? Wish it was more discriptive -,-.




    [Edit]
    To avoid two posts, is it possible to create an array based on an int? IE:
    Code:
    int y=7;
    int x[y];
    Or is their some way I can fool my compiler by using a define? #define x; ?
    Last edited by Blackroot; 01-31-2006 at 11:55 PM.
    Code:
    Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)

  2. #2
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    You had:

    Code:
    class WeakWall {
    
    // ...
    // ...
    
    }
    No semi-colon on end of class structure. Change to:

    Code:
    class WeakWall {
    
    // ...
    // ...
    
    };
    Edit: In response to your edit, look into dynamic memory allocation. Stack-based memory is a fixed size.

  3. #3
    60% Braindead
    Join Date
    Dec 2005
    Posts
    379
    Wow. It works! Thank you tonto, theyse errors really need to be a bit more... Pointed? (Line x, missing semicolin after } -,-) Maybe I should just be more careful :P.

    Thank you again tonto!
    Code:
    Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. gaks bug?
    By Yarin in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 08-31-2008, 03:47 PM
  2. Debugging a rare / unreproducible bug..
    By g4j31a5 in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 08-05-2008, 01:56 PM
  3. ATL bug of CComPtr?
    By George2 in forum Windows Programming
    Replies: 6
    Last Post: 04-07-2008, 08:52 AM
  4. Fixing bug in Quake 2 Engine!
    By hajas in forum Game Programming
    Replies: 4
    Last Post: 06-22-2007, 11:12 AM
  5. What is year 2038 bug?
    By year2038bug in forum A Brief History of Cprogramming.com
    Replies: 67
    Last Post: 09-04-2005, 07:25 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21