P
pazabo
Hi,
I'm trying to somehow implement polymorphic object cloning (just as it
is in Java), but when I write:
class Object {
public:
virtual Object * clone() const = 0;
// ...
}
class String : public Object {
public:
Object * clone() const { return new String(*this); }
// ...
}
compiler tells me, that I cannot allocate object of class String,
because some methods are "pure". There are some more virtual methods in
Object, but there are all implemented in String. What should I do to
solve this problem?
Paul PAZABO Zaborski
I'm trying to somehow implement polymorphic object cloning (just as it
is in Java), but when I write:
class Object {
public:
virtual Object * clone() const = 0;
// ...
}
class String : public Object {
public:
Object * clone() const { return new String(*this); }
// ...
}
compiler tells me, that I cannot allocate object of class String,
because some methods are "pure". There are some more virtual methods in
Object, but there are all implemented in String. What should I do to
solve this problem?
Paul PAZABO Zaborski