Jump to content
  • Advertisement
Sign in to follow this  

classes set in stone

This topic is 5410 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

ok whenever i make a class and compile it to see if what i have so far works out ok ill compile it and (if it works) ill go back to modifying the class what i dont like is how if you forget something you cant just add it with the rest of your functions of the same type (Acssesor methods for examaple) and if you do the compiler turns stupid i dont know exactly what happens but when i compile affter adding something it checks the line the variables were on and if its not there it just decides it must not exist any more. is there any way to fix this because its getting really annoying ill show you what i mean
#include <stdio.h>
#include <stdlib.h>
#pragma once;

//calss for the charicture and the animation there of

class Player
    static const int m_Height = 32 , m_Width = 24;
    static const int m_MHeight = 128, m_MWidth = 72;
    int m_Row, m_Col;
    SDL_Surface *Image;
    void Free();
        Player(SDL_Surface *Image, LPTSTR szFileName);
        BOOL Create(LPTSTR szFileName, SDL_Surface *image);
        int Update(Player *a)
        //acsessor Methods//
        SDL_Surface* GetImage()             {return Image;};
        int GetWidth()                     {return m_MWidth;};
        int GetHeight()                    {return m_MHeight;}; 
        int GetRow()                        {return m_Row * 24;};
        int GetCol()                        {return m_Col * 32;};

any way if theres somthing wrong with my class that dosnt relate to my problem chances are its already on my list of things to do (because im just getting started and this is a "bare-bones" class") and the error it gives me is 29 C:\Dev-Cpp\projects\Homeland\Player.h `m_MWidth' undeclared (first use this function) clearly this has been declared

Share this post

Link to post
Share on other sites
Just make the static const variables public. They can't be modified so there's not really much need for an accessor.

Also, you forgot to put a ; after int Update(Player *a), that may be causing problems further down. I tried adding that and it compiles fine.

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!