Template Specialization (with) inheritance

Hi,

I have to following problem:

I have a template class named something like "BaseClass<type>". Some of the members require different stdlib functions depending on the type used (like strlen for char, something for wchar_t).
So I tried specializing my template ("BaseClass<char>"). But as far as I can see I have to implement ALL of the BaseClass methods because in the specialization they simply do not exist, because the BaseClass template is not the parent class of the specialization.

I googled the problem, tried several solutions but GCC is still complaining.

e.G.:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
template <class type>
class BaseClass {
protected:
    type* a,
    int b;

public:
    someMember(type* x) {
        b = someStdlibCallLikeSTRLEN(x);
    }
};

template <>
class BaseClass<char> {
    ...
};


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
template <>
class BaseClass<char> {
protected:
    type* a,
    int b;

    ...
};

template <class type>
class BaseClass : public BaseClass<char> {
public:
    someMember(type* x) {
        b = someStdlibCallLikeSTRLEN(x);
    }
};


I hope this amount of information helps you finding me a solution, but if requested, of course I will provide more information.

Thank you in advance so much for helping me!

Have a nice weekend

Silberling
will you post the errors you are getting in GCC?

Also, I'm assuming the first bit of code you posted is one version of the code, and the second bit of code you posted is the second version..but both don't exist within the same project.. is this correct?
When you create a template specialization (lines 1-8, second code piece), you can't use "type" anymore.

I don't know what lines 10-16 are doing.
Topic archived. No new replies allowed.