Public Group

# 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.

## 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
{
protected:
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();

public:
////////////////////////////////////////////////////
//Constructor/Destructor//
////////////////////////////////////////////////////
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 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 on other sites
oo ok thanks i forgot that i shouldnt put static costs into a protected thanks again[smile]

• 21
• 16
• 9
• 17
• 13