Invalid cast to abstract class type

  abstract-class, c++

consider the following code:

class BinaryTree{
 virtual bool someMethod() = 0;
 bool operator==(const BinaryTree&); // Comparison of abstract binary tree is possible.
};

class BinaryTreeLnk : virtual public BinaryTree{
 bool someMethod() override;
 bool operator==(const BinaryTreeLnk&);
}

My Professor told me there’s a (logical) problem in operator== of BinaryTree, but since it is an abstract class, I am not being able to figure out how to test it.
Tried to create a BinaryTreeLnk object and cast it to BinaryTree but the compiler says "invalid cast to abstract class type ‘lasd::BinaryTree’".

The Professor himself wrote the comment "Comparison of abstract binary tree is possible." but how is it? Thank you!

Source: Windows Questions C++

LEAVE A COMMENT