E
eselk
If I have:
class A
{
public:
class some_base_class **Obj;
};
And I would like to redefine "Obj" in a class derived from class A,
something like this maybe:
class B : public A
{
public:
class some_other_class **Obj;
};
How would I do that, or is it even possible? If I just use the above
method, class B ends up getting a second copy of Obj, so anything done
to Obj in the base class isn't working with the same pointers... that
isn't what I want.
The reason I want to do this is because class B creates different
objects for the "Obj" array. Whenever I reference Obj from a class B
object I'd like to be able to do it without type-casting. I currently
have something like this all over my code:
TNameRecord *nr = (TNameRecord*) NameRecs->Obj[x];
I'd like to just be able to do this:
TNameRecord *nr = NameRecs->Obj[x];
And if I accidently did this, I'd expect a compiler error:
TNameRecord *nr = MessageRecs->Obj[x];
Because MessageRecs uses some other type of object.
I've searched all over the newsgroups and can't find what I'm looking
for, although I'm sure this question has already been answered. I
guesss I just don't know what the terms are that I need to search for.
class A
{
public:
class some_base_class **Obj;
};
And I would like to redefine "Obj" in a class derived from class A,
something like this maybe:
class B : public A
{
public:
class some_other_class **Obj;
};
How would I do that, or is it even possible? If I just use the above
method, class B ends up getting a second copy of Obj, so anything done
to Obj in the base class isn't working with the same pointers... that
isn't what I want.
The reason I want to do this is because class B creates different
objects for the "Obj" array. Whenever I reference Obj from a class B
object I'd like to be able to do it without type-casting. I currently
have something like this all over my code:
TNameRecord *nr = (TNameRecord*) NameRecs->Obj[x];
I'd like to just be able to do this:
TNameRecord *nr = NameRecs->Obj[x];
And if I accidently did this, I'd expect a compiler error:
TNameRecord *nr = MessageRecs->Obj[x];
Because MessageRecs uses some other type of object.
I've searched all over the newsgroups and can't find what I'm looking
for, although I'm sure this question has already been answered. I
guesss I just don't know what the terms are that I need to search for.