By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,655 Members | 964 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,655 IT Pros & Developers. It's quick & easy.

How to reference a data field of a parent template class

P: n/a

In ansi c++, you can do something like
template <class T>
class vector<T>
{
protected:
int a;
int b;
}

class boundedVector<T> : public vector<T>
{
protected:
int c;
}

And you can use the fields of vector as if they are defined for
boundedVector, but these are no longer allowed by ansi, right?

Xin Wang

Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Xin Wang" <wa****@engr.orst.edu> wrote in message
news:Pi*******************************@flop.ENGR.O RST.EDU...

In ansi c++, you can do something like
template <class T>
class vector<T>
{
protected:
int a;
int b;
}
Missing semi-colon.
class boundedVector<T> : public vector<T>
{
protected:
int c;
}
Missing semi-colon.
And you can use the fields of vector as if they are defined for
boundedVector, but these are no longer allowed by ansi, right?


I don't understand your question. Under what circumstances do you mean "use
the fields of vector as if they are defined for boundedVector"? A
boundedVector<T> inherits the members of vector<T>. It has always been the
case, and remains so, that a class inherits the members of its base
class(es), if any. Is that what you are asking about?

DW
Jul 23 '05 #2

P: n/a

Xin Wang wrote:
In ansi c++, you can do something like
template <class T>
class vector<T>
{
protected:
int a;
int b;
}

class boundedVector<T> : public vector<T>
{
protected:
int c;
}

And you can use the fields of vector as if they are defined for
boundedVector, but these are no longer allowed by ansi, right?

I hope this helps:
http://parashift.com/c++-faq-lite/te...html#faq-35.12

Regards,
Sumit.
--
Sumit Rajan <su*********@gmail.com>

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.