I want to store static strings in subclasses so that they are not duplicated in memory. Can it be done like this? I want to be able to instantiate two IBMs but only put the string "IBM" once in memory.
class Company {
static const std::string company_name;
}
class CocaColaCompany : public Company {
static const std::string company_name = "Coca Cola";
}
class IBM : public Company {
static const std::string company_name = "IBM";
}
Or is there a problem with using static members with a polymorphic base class?