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;
};