|
-
March 4th, 2001, 03:02 PM
#1
Template Class
I would like to modify my existing class to be a template class, so that I could use it with different data formats.
What changes do I have to make to my class to make it a template class? Are there any other things(problems) to consider when I'm using a template class?
-
March 6th, 2001, 03:10 AM
#2
Re: Template Class
You have only to declare the template like that:
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_TEXTILTYPE,
RUNTIME_CLASS(CTextilDoc),
RUNTIME_CLASS(CMDIChildWnd), // standard MDI child frame
RUNTIME_CLASS(CTextilView));
AddDocTemplate(pDocTemplate);
-
March 6th, 2001, 04:18 AM
#3
Example of a template class...
// Very broad example
template <class Type> class CExample
{
public:
CExample() : m_Value(0)
{
}
virtual ~CExample()
{
m_Value = 0;
}
void SetValue(const Type & rhs)
{
m_Value = rhs;
}
Type GetValue() const
{
return m_Value;
}
protected:
Type m_Value;
};
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|