Thanks for the help,
KnifeMissile, the compliment and the advice about smilies (I hadn't seen the option :) )
This is what I came up with myself - I'm not sure if it's just another instance of your result but it seems to work too:
Code:
class dog
{
public:
int const *numb;
void print_data()
{ cout << *numb << "\n"; };
};
class collie : public dog
{
public:
static int const numb;
collie(){dog::numb=&collie::int_numb;};
};
int const collie::int_numb=111;
class spaniel : public dog
{
public:
static int const int_numb;
spaniel(){dog::numb=&spaniel::int_numb;};
};
int const spaniel::int_numb=555;
I've confusingly removed the arrays (when I realised it wasn't the fact it was an array that was the problem in the real code) and not bothered making int_numb private here. Any thoughts?
On reading around I've decided what I really was looking for was something like:
Code:
/* not valid C++ but I'd like it to be :) */
class dog
{
public:
virtual int numb;
void print_data()
{ cout << numb << "\n"; };
};
class spaniel
{
public:
static int const numb;
};
/* etc.... */
Thanks for all the help - C++ looks interesting once I can shoehorn it into my way of thinking...
EDIT to take
Knifemissile's advice about const and data location... hope that's right!