Jump to content
  • Advertisement
Sign in to follow this  

I have three error using allegro and C++

This topic is 3968 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

#include <allegro.h>
#include <cstdlib>
#include <time.h>
#define edeadplace 250
#define pdeadplace 70
#define p 100
#define e 540
#define y 240
#define center 320

bool gamenotquit = true;

class allthings
      int level;
      int attackcount;
      int strikecount;
      int attacktime;
      int striketime;
      bool haswon;
      bool failure;
             void declaration();
             void faillevel();
             void playerwin();
             void enemywin();
             void attacktie();
             void enemyattack();
             void playerattack();
             void nextlevel();
             void menu();
             void resetlevel();
             void warscreen();
             void attackplus();
             void strikeplus();

                      level = 1;
                      attackcount = 0;
                      strikecount = 0;
                      attacktime = 0;
                      striketime = 0;
                      haswon = false;
                      failure = false;
                      player = load_bitmap("player.bmp",NULL);
                      playera = load_bitmap("playera.bmp",NULL);
                      playerd = load_bitmap("playerd.bmp",NULL);
                      zyars = load_bitmap("zyars.bmp",NULL);
                      zyarsa = load_bitmap("zyarsa.bmp",NULL);
                      zyarsd = load_bitmap("zyarsd.bmp",NULL);
                      vandy = load_bitmap("vandy.bmp",NULL);
                      vandya = load_bitmap("vandya.bmp",NULL);
                      vandyd = load_bitmap("vandya.bmp",NULL);
                      mitsu = load_bitmap("mitsu.bmp",NULL);
                      mitsua = load_bitmap("mitsua.bmp",NULL);
                      mitsud = load_bitmap("mitsud.bmp",NULL);
                      ryoku = load_bitmap("ryoku.bmp",NULL);
                      ryokua = load_bitmap("ryokua.bmp",NULL);
                      ryokud = load_bitmap("ryokud.bmp",NULL);
                      drksp = load_bitmap("drksp.bmp",NULL);
                      drkspa = load_bitmap("drkspa.bmp",NULL);
                      drkspd = load_bitmap("drkspd.bmp",NULL);
                      champion = load_bitmap("champion.bmp",NULL);
                      valley = load_bitmap("valley.bmp",NULL);
                      redraw = load_bitmap("redraw.bmp",NULL);
                      start = load_bitmap("start.bmp",NULL);
                      start = load_bitmap("failx.bmp",NULL);

void allthings::attackplus()
void allthings::strikeplus()

... //<-- a hundred lines of random stuff

void allthings::menu()
     else if(key[KEY_ESC])
                         gamenotquit = true;

int main()
    allthings*control = new allthings;
    while(gamenotquit == true)
     delete *control;
     return 0;

I have three error, "argument of type void(allthings::)()does not match void(*)()" For the two install_int_ex lines in allthings constructor "menu undeclared, first use this function" "type class allthings argument given to delete, expected pointer" I can understand none of these! :( I'm so close, I can touch the goal... but then not with my feet, which are the only parts that count in a race... So sorry if I do not include enough code or do something wrong, please ask me =)

Share this post

Link to post
Share on other sites

allthings*control = new allthings;

while(gamenotquit == true)

Your menu is undeclared because it was defined within a class (allthings), so it must be accessed through an object of type allthings.

What you've done - put all things in a class - is not the purpose of classes. Classes should be used to encapsulate things that are relevant to each other. For instance, you would have a Unit class that handles everything relating to a unit (including both the user's unit i.e. character, as well as enemy units). By putting all the relevant data into a class, you can then create a ton of objects of that class (you could create 11 Units, 1 Unit for your user to control and 10 Unit's to serve as the users enemies).

What I'm getting to is that you should probably take everything out of that class and create several smaller classes that contain only relevant things. In this particular case, menu() wouldn't really belong in the Unit class since the menu has nothing to do with a Unit.

So, you would want to make menu() a global function.

But, if you don't want to do all of what I just said, then you've already created an object of type allthings in your code, but when you call menu() you have to access it through your object of type allthings (since menu() is contained in the allthings class).

So you would do: control->menu()

As for "type class allthings argument given to delete, expected pointer," that error comes from this line (obviously) delete *control;.

The problem is that you've included a *, which will de-reference the object that your pointer points to. In other words, *control is of type allthings (since control points to an object of type allthings), but delete only wants a pointer, not an object, so you don't want to include that *.

Change your code to: delete control

Share this post

Link to post
Share on other sites
Shakedown is correct; there's really no point in one giant class that does everything. It's no better than just having a bunch of free functions, really.


"argument of type void(allthings::)()does not match void(*)()"
For the two install_int_ex lines in allthings constructor

install_int_ex expects a pointer to a function which takes no parameters and returns nothing (ie, a void (*)()). You've instead provided a pointer to a member function which takes no parameters and returns nothing (ie, a void(allthings::*)()). Make attackplus and strikeplus static, or remove them from the allthings class.


"menu undeclared, first use this function"

You want control->menu() not menu().


"type class allthings argument given to delete, expected pointer"

You want delete control not delete *control

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!