|
initialising static members of template classes
the following code compiles and works ok. the problem arises when i make 'num' a reference, ie change the line
static int x;
with
static int& x; //notice x is now a reference
borland compiler gives redeclaration errors. am i missing somethig obvious here?
is it possible to get around this?
Edited by - Yorvik on January 17, 2001 11:08:41 AM
Don''t put template<> before the definitions of the static vars. Like this:
int& Base::nu = i;
float& Base::num = j;
int& Base
float& Base
January 18, 2001 08:03 PM
quote:
Original post by Morbo
Don''t put template<> before the definitions of the static vars. Like this:
int& Base::nu = i;
float& Base::num = j;
I don''t know but that don''t seem right to me.
Isn''t this how it''s supposed to work...?
|
I''m by no means an expert, but it seems more likely to me.
AP: the "class T" is not required, the compiler deduces the type from the < int > later on.
Morbo: template<> is required (in bcc5.5 anyway)
anyone have any ideas? if not im gonna have to use #defines, and i REALLY dont want to do that.
Edited by - Yorvik on January 19, 2001 10:12:28 AM
Morbo: template<> is required (in bcc5.5 anyway)
anyone have any ideas? if not im gonna have to use #defines, and i REALLY dont want to do that.
Edited by - Yorvik on January 19, 2001 10:12:28 AM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement