How to access member of template in C++

Ryland

Platinum Member
Aug 9, 2001
2,810
13
81
I have a class with a template like:

Code:
template< class ReqDataType, bool DisplayErrors, class RespDataType = RespItems >
class TransBase: public TransBaseSuper
{
...
}

and I need to be able to change DisplayErrors in subclasses but the compiler keeps balking an saying that DisplayErrors doesn't exist. Is there a way to do this?
 

mlm

Senior member
Feb 19, 2006
933
0
0
That's looks absolutely nothing like the templates we've been working with in a class I'm taking. Have you been able to get them to work like that before in the past? Those look like they should be typedefs within the class.
 

dighn

Lifer
Aug 12, 2001
22,820
4
81
How are you trying to "change" DisplayErrors? Can you give more info? Some snippet of what you are trying to do would be helpful.
 

Templeton

Senior member
Oct 9, 1999
467
0
0
You can't. The value is statically bound at the point of instantiation. If you want a different value used, then instantiate the template with this value.
 

Ryland

Platinum Member
Aug 9, 2001
2,810
13
81
Another guy I work with took a look at it and came back with the statically bound answer (it essentially turns into a #define type thing).

I didn't design the original class and that boolean should not be in the template design but it is and there is nothing I can do to change it.

Thanks all
 

sao123

Lifer
May 27, 2002
12,653
205
106
Originally posted by: Ryland
I have a class with a template like:

Code:
template< class ReqDataType, bool DisplayErrors, class RespDataType = RespItems >
class TransBase: public TransBaseSuper
{
...
}

and I need to be able to change DisplayErrors in subclasses but the compiler keeps balking an saying that DisplayErrors doesn't exist. Is there a way to do this?


wow... that code is badly written...
 

Ryland

Platinum Member
Aug 9, 2001
2,810
13
81
Luckily it was not written by me but by another company. I just get stuck dealing with it.