Re: Question about large objects
JoeC <enki034@yahoo.com> wrote in message ...
[snip]
Good advice. I am trying to take what I read and create my own
projects. I like the ask questions on what I have done so see if I am
implementing concepts correctly. Here is my next generation of
graphics objects it is much more divided:
// again, put the guards around all:
#ifndef GRBIN_H
#define GRBIN_H
#include<windows.h>
#include<vector>
#include "graphics.h"
#include "color.h"
#include "coord.h"
// > #ifndef GRBIN_H
// > #define GRBIN_H
class grBin{ protected:
graphics * gr;
std::vector<color>colors;
coord loc;
public:
~grBin(){delete gr;}
void display(HWND, const int, const int);
void displayClear(HWND, const int, const int);
void displayBig(HWND, const int, const int);
int getX(){return loc.x;}
int getY(){return loc.y;}
};
This game is a different concept and is still in progress. In my last
game I did create a handle in case I wanted different kinds of units:
#ifndef HUNIT_H
#define HUNIT_H
#include<windows.h>
#include<fstream>
#include "unit.h"
#include "grboard.h"
// > #ifndef HUNIT_H
// > #define HUNIT_H
class hunit{
unit * p;
int * cnt;
void make(HWND, char, DWORD, int, int, bool);
public:
hunit() : cnt(new int(1)), p(new unit) {}
hunit(HWND, char, DWORD);
hunit(HWND, char, DWORD, int, int);
hunit(HWND, char, DWORD, int, int, bool);
You may be able to reduce the number of constructors here by using
default values.
// hunit(HWND, char, DWORD);
// hunit(HWND, char, DWORD, int, int);
// following line not syntax correct (for posting)
hunit(HWND, char, DWORD, int I1 = 0, int I2 = 0, bool flag = false);
Then you can 'call' it with 3, 4, 5 or 6 parms. as needed. It's a
style/design thing. If you don't understand, experiment a little, then
decide.
IMHO, I'd also watch out for how/where you use 'HWND' and 'DWORD'. If you
ever go to a GNU/Linux box, you will get a great headache changing all
instances of those. (you do know about wxWidgets, don't you?). 'DWORD'
sounds to me like a define/typedef of 'long' (32bit+ type), so, maybe use
that if you can. Just something to think about, the choice is always yours.
--
Bob R
POVrookie