Well, apparently, I cannot. But that's my problem. Maybe it's a design issue and I'm getting the whole thing wrong.
I would like to have a class member initialized differently within each derived class. Imagine I have an object of type Device
. This Device
is just an interface used by the application code, because the actual devices are just one of two types, DeviceA
or DeviceB
. There are some features common to all devices, like, say, the name. That should be then a class member, shouldn't it? So I'd have:
class Device {
static std::string sm_name;
}
But each family device has its own name. How could I initialize the name to a different value for each derived class? Is the design wrong? Should the name property not be a class member?