473,324 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

member template -- reusing type information?

Hello,
I have my inline class definition below. I have my member template
constructors which initialize my "data" object. The problem is the
CheckOne() function, which uses the T1 template argument. I want it to
iterate over "data" with the same T1 datatype that was used to
construct the data object in the IndividualRecord constructor. That is
it needs to remember what is T1 and use the same datatype. Every way I
tried gives an error, can you help? thanks

template <class DATA>
template<DATA>
class IndividualRecord
{
public:
DATA data;
public:
bool isWritten;

IndividualRecord(const IndividualRecord&
r):isWritten(false),data(r.data){}

IndividualRecord& operator==(const IndividualRecord& r)const
{
return data==r.data;
}
template <class T1>
IndividualRecord(const T1 p1):isWritten(false),data(p1){}
template <class T1, class T2>
IndividualRecord(const T1 p1,const T2 p2):isWritten(false),data(p1,p2)
{}
template <class T1, class T2, class T3>
IndividualRecord(const T1 p1,const T2 p2,const T3
p3):isWritten(false),data(p1,p2,p3){}
....

bool CheckOne()
{
bool results = 0;
vector<T1>::iterator Iter;
vector<T1>::iterator Iter2;
for (Iter = data.p1.begin(); Iter != data.p1.end(); Iter++ ) //
iterate over the inside variable
{
for (Iter2 = outside.data.p1.begin(); Iter !=
outside.data.p1.end(); Iter++) // iterate over outside variable
to see if anything matches
{
if (*Iter == *Iter2)
results = 1;
}
}
return results;

};
Aug 9 '08 #1
0 990

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Gianni Mariani | last post by:
I remember seeing a neat template specialization trick posted here a few months ago that allowed the detection of a type containing a member. After a day searching through google archives I come up...
11
by: Matthias | last post by:
Hello, templated virtual member functions are not allowed. Now I am searching for a good workaround for this problem, but I can't find any. Here's my problem: class Base { template...
3
by: danilo.horta | last post by:
Hi guys I'm trying to accomplish a slightly difficult task. I think it's more easy to explain trought an unworking code: template<class T, size_t numDim> VecBasis {/*...*/}; typedef...
5
by: jknupp | last post by:
In the following program, if the call to bar does not specify the type as <int>, gcc gives the error "no matching function for call to ‘bar(A&, <unresolved overloaded function type>)’". Since bar...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.