OK, here's another tough implementation problem.
CTmplStringBase will have one of two functions depending on what type T is, so naturally to this, a specialized template would be required.
Unfortunately, that means I have to create a new class and inherit from, else I would have to remake the entire class in the specialization.
But this new class returns an object of the class it inherits from, so it, in turn, needs the inheriting class to be defined first.
But then, the code won't compile because CTmplStringBase would try to derive from an undefined class.
So what's a solution to this?
CTmplStringBase wants to derive from StrConversions:
Code:
template<typename T, typename Traits> class CTmplStringBase:
public StrConversion<T>,
Because it wants access to specialized template member functions:
Code:
template<typename T> class StrConversion { };
template<> class StrConversion<char>
{
public:
CStringExW ToUTF16();
private:
virtual const char* GetData() = 0;
};
template<> class StrConversion<wchar_t>
{
public:
CStringExA ToANSI();
private:
virtual const wchar_t* GetData() = 0;
};
But StrConversion wants to return objects of CTmplStringBase, so I get circular dependencies.