Is there a better way to access the base class operator overload? I'm using casting, and it works just fine, just wondering if there is a better way. Is this bad/ugly code?
class StrategyKey
{
public:
StrategyKey(){}
~StrategyKey(){}
StrategyKey(const char* strA):
str_strategy(strA)
{}
friend bool operator< (const StrategyKey& stratKeyA, const StrategyKey& stratKeyB)
{
if (stratKeyA.str_strategy < stratKeyB.str_strategy)
return true;
else
return false;
}
std::string str_strategy;
};
class TechniqueKey : public StrategyKey
{
public:
TechniqueKey(){}
~TechniqueKey(){}
TechniqueKey(const char* strA, const char* strB): StrategyKey(strB),
str_technique(strA)
{}
friend bool operator< (const TechniqueKey& stratKeyA, const TechniqueKey& stratKeyB)
{
if (stratKeyA.str_technique < stratKeyB.str_technique)
return true;
else if (stratKeyA.str_technique == stratKeyB.str_technique)
return (StrategyKey)stratKeyA < (StrategyKey)stratKeyB;
else
return false;
}
string str_technique;
};