473,503 Members | 1,739 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to reference a data field of a parent template class


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
2 1483
"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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2380
by: Carlos Ribeiro | last post by:
Hello all, I'm posting this to the list with the intention to form a group of people interested in this type of solution. I'm not going to spam the list with it, unless for occasional and...
16
2648
by: Suzanne Vogel | last post by:
Hi, I've been trying to write a function to test whether one class is derived from another class. I am given only id's of the two classes. Therefore, direct use of template methods is not an...
10
2250
by: Tony Johansson | last post by:
Hello Experts!! This class template and main works perfectly fine. I have this class template called Handle that has a pointer declared as T* body; As you can see I have a reference counter in...
2
2177
by: Roy | last post by:
Ok, this is incredibly annoying. Below I have an ImageButton and it's ImageButton_Click sub. See the 6 response.writes? The output for them is displayed below in asterisks. Question: What part of...
3
2195
by: Richard Carpenter | last post by:
I understand how to use a dropdown list control to display the associated description value for a foreign key in a parent rather than the key itself, but I don't like having to disable the control...
9
3991
by: Anil Gupte | last post by:
After reading a tutorial and fiddling, I finally got this to work. I can now put two tables created with a DataTable class into a DataRelation. Phew! And it works! Dim tblSliceInfo As New...
2
3901
by: Imre | last post by:
Hi I know that offsetof is basically a C leftover, and only works for POD types, not classes, so it is recommended that I use pointers to members instead. However, I have a problem where I don't...
2
1214
by: Anonymous | last post by:
template<class T> class A { public: A() { T * object = new T(this); //passing instance as parent of nested class m_obj.push_back(object); } ~A() {
2
1276
by: Anonymous | last post by:
template<class T> class A { public: A() { T * object = new T(this); //passing instance as parent of nested class m_obj.push_back(object); } ~A() {
0
7281
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7334
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6993
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7462
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3156
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1514
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
737
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.