So far I have done the following work:
class Stamp{
public:
virtual std::string GetStampName() const { return "undefined"; }
};
class FooStamp : public Stamp {
public:
std::string GetStampName() const override { return "foo-stamp"; }
};
I use it like this:
FooStamp fooStamp;
std::cout << "foo-stamp:" << fooStamp.GetStampName() << std::endl;
const Stamp stamp = fooStamp;
std::cout << "stamp:" << stamp.GetStampName() << std::endl;
The actual output is as follows:
foo-stamp:foo-stamp
stamp:undefined // expected: foo-stamp
Types converted to base classes are not working. What did i do wrong.
Is there a way to make the override effective also ensure that the object is copied by value.