Click here to Skip to main content
15,918,742 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to Let The webpage auto-download the DLL-file and Registe it on client. Pin
super9-Jan-03 19:16
professionalsuper9-Jan-03 19:16 
GeneralCross dependent headers Pin
Dan Watt9-Jan-03 18:32
Dan Watt9-Jan-03 18:32 
GeneralRe: Cross dependent headers Pin
Michael Dunn9-Jan-03 20:16
sitebuilderMichael Dunn9-Jan-03 20:16 
GeneralTemplates Pin
Stan the man9-Jan-03 16:41
Stan the man9-Jan-03 16:41 
GeneralRe: Templates Pin
Dave Bryant9-Jan-03 17:23
Dave Bryant9-Jan-03 17:23 
GeneralRe: Templates Pin
Michael Dunn9-Jan-03 18:27
sitebuilderMichael Dunn9-Jan-03 18:27 
GeneralRe: Templates Pin
Stan the man9-Jan-03 18:46
Stan the man9-Jan-03 18:46 
GeneralRe: Templates Pin
Michael Dunn9-Jan-03 19:51
sitebuilderMichael Dunn9-Jan-03 19:51 
(Note for the future: you need to escape < and > (use the buttons below the sig box if you're in IE/Mozilla) for template syntax to appear correctly.)

There are two ways to approach deriving from a template class. 1, you can make the derived class a template; or 2, you can derive from a specialization of the base class. Take this class:
template <typename T>
class A
{
public:
    A ( T t ) : m_t(t) { }
    T m_t;
};
 
// now declare a variable
A<char> a_obj('x');
Pretty simple class with one data member, whose type is passed as the template param. If I want to make a derived class, I can write this:
class B : public A<int>
{
public:
    B(int n) : A<int>(n) { }
};
 
// now declare a variable:
B b_obj(1);
Note that objects of type class B will only use the A<int> specialization. You can't have a class B object use, say A<unsigned long>.

The other way is to have the derived class be a template:
template <typename T>
class C : public A<T>
{
public:
    C(T t) : A<T>(t) { }
};
 
// now declare a variable:
C<double> c_obj(3.14);  // derives from A<double>
Of course, you can always make the derived class more complicated if you need to:
template <typename T, typename U>
class D : public A<T>
{
public:
    D(T t) : A<T>(t), m_u(0) { }
    U m_u;
};
 
// variable:
D<float,int> d_obj(2.71828);  // derives from A<float>
Yes, the syntax sucks. You just have to keep staring at it and seeing examples until it sinks in. Wink | ;)

--Mike--
I'm bored... Episode I bored.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm

GeneralRe: Templates Pin
Stan the man10-Jan-03 2:57
Stan the man10-Jan-03 2:57 
GeneralRe: Templates Pin
Michael Dunn10-Jan-03 7:08
sitebuilderMichael Dunn10-Jan-03 7:08 
GeneralRe: Templates Pin
Dave Bryant12-Jan-03 7:31
Dave Bryant12-Jan-03 7:31 
GeneralRe: Templates Pin
Vicar29-Jan-03 19:24
Vicar29-Jan-03 19:24 
QuestionCheck visibility of a child control? Pin
Moak9-Jan-03 15:32
Moak9-Jan-03 15:32 
AnswerRe: Check visibility of a child control? Pin
Moak10-Jan-03 6:43
Moak10-Jan-03 6:43 
GeneralI am in DLL Hell.. :( Pin
VanHlebar9-Jan-03 14:43
VanHlebar9-Jan-03 14:43 
GeneralRe: I am in DLL Hell.. :( Pin
Rick York9-Jan-03 15:15
mveRick York9-Jan-03 15:15 
GeneralRe: I am in DLL Hell.. :( Pin
VanHlebar9-Jan-03 16:43
VanHlebar9-Jan-03 16:43 
GeneralRe: I am in DLL Hell.. :( Pin
Chris Richardson9-Jan-03 17:57
Chris Richardson9-Jan-03 17:57 
GeneralRe: I am in DLL Hell.. :( Pin
Rickard Andersson209-Jan-03 21:45
Rickard Andersson209-Jan-03 21:45 
GeneralRe: I am in DLL Hell.. :( Pin
Rick York10-Jan-03 5:41
mveRick York10-Jan-03 5:41 
QuestionWhat is OLE object? Pin
E_LISE_LI9-Jan-03 14:10
E_LISE_LI9-Jan-03 14:10 
AnswerRe: What is OLE object? Pin
Michael Dunn9-Jan-03 14:30
sitebuilderMichael Dunn9-Jan-03 14:30 
Generalrepost Numbers won't display in HEX when using string class Pin
Perseus9-Jan-03 13:07
Perseus9-Jan-03 13:07 
GeneralRe: repost Numbers won't display in HEX when using string class Pin
Michael Dunn9-Jan-03 14:32
sitebuilderMichael Dunn9-Jan-03 14:32 
GeneralRe: repost Numbers won't display in HEX when using string class Pin
Perseus9-Jan-03 14:41
Perseus9-Jan-03 14:41 

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.