Click here to Skip to main content
16,005,697 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralReading a large file Pin
Tom Wright22-Apr-04 12:35
Tom Wright22-Apr-04 12:35 
GeneralRe: Reading a large file Pin
valikac22-Apr-04 15:04
valikac22-Apr-04 15:04 
GeneralRe: Reading a large file Pin
hasansheik22-Apr-04 23:50
hasansheik22-Apr-04 23:50 
GeneralRe: Reading a large file Pin
Tom Wright23-Apr-04 4:38
Tom Wright23-Apr-04 4:38 
GeneralSTL list object Pin
mjackson1122-Apr-04 12:27
mjackson1122-Apr-04 12:27 
GeneralRe: STL list object Pin
valikac22-Apr-04 15:10
valikac22-Apr-04 15:10 
GeneralRe: STL list object Pin
Michael Dunn22-Apr-04 16:40
sitebuilderMichael Dunn22-Apr-04 16:40 
GeneralRe: STL list object Pin
mjackson1122-Apr-04 17:46
mjackson1122-Apr-04 17:46 
Here is the code

namespace mrg
{
template<class _Ty> class mrgFwdPt
{
public:
mrgFwdPt()
{
}

mrgFwdPt(_Ty v, Date dt) : _mVal(v), _mFwdDt(dt)
{
}

~mrgFwdPt()
{
}

inline void SetValue(_Ty v) { _mVal = v; }
inline void SetDate(Date d) { _mFwdDt = d; }

inline _Ty GetValue(void) { return _mVal; }
inline Date GetFwdDt(void) { return _mFwdDt; }

// these operators work on the date objects to allow
// sorting of the forward points by date
bool operator>(const mrgFwdPt<_Ty>& right) const;
bool operator<(const mrgFwdPt<_Ty>& right) const;
bool operator>=(const mrgFwdPt<_Ty>& right) const;
bool operator<=(const mrgFwdPt<_Ty>& right) const;
bool operator==(const mrgFwdPt<_Ty>& right) const;
bool operator!=(const mrgFwdPt<_Ty>& right) const;

protected:
_Ty _mVal;
Date _mFwdDt;
};

template<class _Ty> bool mrgFwdPt<_Ty>::operator>(const mrgFwdPt<_Ty>& right) const
{
return (_mFwdDt > right._mFwdDt);
}

template<class _Ty> bool mrgFwdPt<_Ty>::operator<(const mrgFwdPt<_Ty>& right) const
{
return (_mFwdDt < right._mFwdDt);
}

template<class _Ty> bool mrgFwdPt<_Ty>::operator>=(const mrgFwdPt<_Ty>& right) const
{
return (_mFwdDt >= right._mFwdDt);
}

template<class _Ty> bool mrgFwdPt<_Ty>::operator<=(const mrgFwdPt<_Ty>& right) const
{
return (_mFwdDt <= right._mFwdDt);
}

template<class _Ty> bool mrgFwdPt<_Ty>::operator==(const mrgFwdPt<_Ty>& right) const
{
return (_mFwdDt == right._mFwdDt);
}

template<class _Ty> bool mrgFwdPt<_Ty>::operator!=(const mrgFwdPt<_Ty>& right) const
{
return (_mFwdDt != right._mFwdDt);
}
//=========================== end of point class ==========================================//

template<class _Ty> class mrgFwdCrv
{
public:
mrgFwdCrv()
{
}
~mrgFwdCrv()
{
}

bool push_back(mrgFwdPt<class _Ty> fp)
{
_mList.push_back(fp);
return true;
}

bool test_sort(void);

private:
list<mrgFwdPt<class _Ty>> _mList;
};

template<class _Ty> bool mrgFwdCrv<_Ty>::test_sort(void)
{
Date d;
list <mrgFwdPt<class _Ty>>::iterator i;

for (i = _mList.begin(); i != _mList.end(); i++)
{
d = (*i)->GetFwdDt();
cout << d.DateString() << endl;
}

_mList.sort(less<mrgFwdPt<class _Ty>>());

for (i = _mList.begin(); i != _mList.end(); i++)
{
d = (*i)->GetFwdDt();
cout << d.DateString() << endl;
}
}

}

Class mrgFwdPt is a templated class. It works exactly as expected. When the second class mrgFwdCrv is added, the compiler chokes and I get all kinds of errors. What I would like to do is have the second class (mrgFwdCrv) handle a list of the mrgFwdPt classes. I thought about the typedef approach but wouldn't the compiler just make the substitutions I have here?

Thx
GeneralRe: STL list object Pin
Maxwell Chen22-Apr-04 19:07
Maxwell Chen22-Apr-04 19:07 
GeneralRe: STL list object Pin
mjackson1123-Apr-04 1:37
mjackson1123-Apr-04 1:37 
GeneralChar* -&gt; DWORD conversion Pin
__Cerb22-Apr-04 11:14
__Cerb22-Apr-04 11:14 
GeneralRe: Char* -&gt; DWORD conversion Pin
ravjak22-Apr-04 11:28
ravjak22-Apr-04 11:28 
GeneralRe: Char* -&gt; DWORD conversion Pin
__Cerb22-Apr-04 11:31
__Cerb22-Apr-04 11:31 
GeneralRe: Char* -&gt; DWORD conversion Pin
Michael Dunn22-Apr-04 16:42
sitebuilderMichael Dunn22-Apr-04 16:42 
GeneralProblem overloading operators in templated classes Pin
22-Apr-04 10:36
suss22-Apr-04 10:36 
GeneralRe: Problem overloading operators in templated classes Pin
mjackson1122-Apr-04 12:29
mjackson1122-Apr-04 12:29 
GeneralTest your C++ knowledge with these questions! Pin
soer22-Apr-04 10:17
soer22-Apr-04 10:17 
GeneralRe: Test your C++ knowledge with these questions! Pin
Navin22-Apr-04 10:39
Navin22-Apr-04 10:39 
GeneralRe: Test your C++ knowledge with these questions! Pin
Antony M Kancidrowski22-Apr-04 10:58
Antony M Kancidrowski22-Apr-04 10:58 
GeneralRe: Test your C++ knowledge with these questions! Pin
ravjak22-Apr-04 11:33
ravjak22-Apr-04 11:33 
GeneralRe: Test your C++ knowledge with these questions! Pin
soer22-Apr-04 16:21
soer22-Apr-04 16:21 
GeneralRe: Test your C++ knowledge with these questions! Pin
FlyingDancer22-Apr-04 14:27
FlyingDancer22-Apr-04 14:27 
QuestionHow to display a transparent PNG using CxImage??? Pin
randythawkins22-Apr-04 9:21
randythawkins22-Apr-04 9:21 
Generaldrawing dot and rect Pin
lvidot22-Apr-04 7:22
lvidot22-Apr-04 7:22 
GeneralRe: drawing dot and rect Pin
jmkhael22-Apr-04 7:32
jmkhael22-Apr-04 7:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.