T
Thomas Matthews
Hi,
I have a class Record which is a container of fields.
I have overloaded operator[] to return a pointer to a Field:
class Field; // Forward declaration
class Record
{
public:
Field * operator[](unsigned int index);
};
I have defined a class, Keyed_Record, which is-a Record
that has Keys associated with it:
class Key;
class Keyed_Record
: public Record
{
std::vector<Key *> keys;
};
My issue is that operator[] is not working for the
Keyed_Record class. I've searched the FAQ and Bruce
Eckel's book and didn't find anything. Unfortunately,
my Stroustup book is at home and my electronic copy
of the standard is on my home computer.
Is there any reason that operator[] is not inherited
by Keyed_Record?
I'm using Borland 6, if that makes any difference.
Here is an application of the operator[] for the
Keyed_Record:
int main(void)
{
Field * pf;
Keyed_Record kr;
pf = kr[1]; // Return pointer to second field
// in keyed record.
return 0;
}
--
Thomas Matthews
C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
I have a class Record which is a container of fields.
I have overloaded operator[] to return a pointer to a Field:
class Field; // Forward declaration
class Record
{
public:
Field * operator[](unsigned int index);
};
I have defined a class, Keyed_Record, which is-a Record
that has Keys associated with it:
class Key;
class Keyed_Record
: public Record
{
std::vector<Key *> keys;
};
My issue is that operator[] is not working for the
Keyed_Record class. I've searched the FAQ and Bruce
Eckel's book and didn't find anything. Unfortunately,
my Stroustup book is at home and my electronic copy
of the standard is on my home computer.
Is there any reason that operator[] is not inherited
by Keyed_Record?
I'm using Borland 6, if that makes any difference.
Here is an application of the operator[] for the
Keyed_Record:
int main(void)
{
Field * pf;
Keyed_Record kr;
pf = kr[1]; // Return pointer to second field
// in keyed record.
return 0;
}
--
Thomas Matthews
C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book