派生类可以小于其父类吗?

我问这个问题是因为我很熟悉C ++,但是这个问题确实可以自我解释:是否有一种语言可以派生一个类并使它比原始类占用更少的内存?

这个问题比我要解决的实际问题更多的是一个头,但我可以想象一些真正高性能的代码可以从这种内存优化中受益:

假设我们有:

class Person {
    std::string name;
    unsigned int age;
}

class PersonNamedJared {
}

从理论上讲,在此子类中我们不需要字段“名称”,因为它始终为“ Jared”,这可以提高内存效率。

Is the only way to make this happen by replacing the 'name' field in Person with a get_name() function that we simply override in PersonNamedJared to always return "Jared"? How would we still make the name variable in the base class?

我知道这个例子确实是不好的做法,但这是我能想到的最好的例子。我认为实施这种模式是有正当理由的。