• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

How to access member of template in C++

Ryland

Platinum Member
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?
 
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.
 
How are you trying to "change" DisplayErrors? Can you give more info? Some snippet of what you are trying to do would be helpful.
 
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.
 
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
 
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...
 
Luckily it was not written by me but by another company. I just get stuck dealing with it.
 
Back
Top