S
Siegfried Heintze
How do I use a template to write these friend functions once? The are nearly
identical. Also, why does wcout << L'A'; print 65 instead of a character?
Thanks,
Siegfried
struct DVDDeltaTime{
// constructors go here...
friend std:stream & operator<<(std:stream &os, const DVDDeltaTime&
dt ){
return os
<< ' ' << std::setw(2) << std::setfill('0') << dt.m_nTitles
<< ':' << std::setw(2) << std::setfill('0') << dt.m_nHours
<< ':' << std::setw(2) << std::setfill('0') << dt.m_nMinutes
<< ':' << std::setw(2) << std::setfill('0') << dt.m_nSeconds
<< ':' << std::setw(2) << std::setfill('0') << dt.m_nFrames;
}
friend std::wostream & operator<<(std::wostream &os, const DVDDeltaTime&
dt ){
return os
<< L" " << std::setw(2) << std::setfill(L'0') << dt.m_nTitles
<< L":" << std::setw(2) << std::setfill(L'0') << dt.m_nHours
<< L":" << std::setw(2) << std::setfill(L'0') << dt.m_nMinutes
<< L":" << std::setw(2) << std::setfill(L'0') << dt.m_nSeconds
<< L":" << std::setw(2) << std::setfill(L'0') << dt.m_nFrames ;
}
private:
unsigned m_nTitles:8, m_nHours:6, m_nMinutes:6, m_nSeconds:6,
m_nFrames:6;
}
identical. Also, why does wcout << L'A'; print 65 instead of a character?
Thanks,
Siegfried
struct DVDDeltaTime{
// constructors go here...
friend std:stream & operator<<(std:stream &os, const DVDDeltaTime&
dt ){
return os
<< ' ' << std::setw(2) << std::setfill('0') << dt.m_nTitles
<< ':' << std::setw(2) << std::setfill('0') << dt.m_nHours
<< ':' << std::setw(2) << std::setfill('0') << dt.m_nMinutes
<< ':' << std::setw(2) << std::setfill('0') << dt.m_nSeconds
<< ':' << std::setw(2) << std::setfill('0') << dt.m_nFrames;
}
friend std::wostream & operator<<(std::wostream &os, const DVDDeltaTime&
dt ){
return os
<< L" " << std::setw(2) << std::setfill(L'0') << dt.m_nTitles
<< L":" << std::setw(2) << std::setfill(L'0') << dt.m_nHours
<< L":" << std::setw(2) << std::setfill(L'0') << dt.m_nMinutes
<< L":" << std::setw(2) << std::setfill(L'0') << dt.m_nSeconds
<< L":" << std::setw(2) << std::setfill(L'0') << dt.m_nFrames ;
}
private:
unsigned m_nTitles:8, m_nHours:6, m_nMinutes:6, m_nSeconds:6,
m_nFrames:6;
}