#include <iostream>
#include <cmath>
#include <sstream>
using namespace std;
class aa;
class bb;
class root
{
public:
virtual ~root() {}
virtual root add(const aa& a) const=0;
virtual root add(const bb& a) const=0;
};
class aa: public root
{
public:
aa() { }
aa(const aa& a) { }
virtual root add(const aa& a) const
{ return root(new aa()); }
virtual root add(const bb& a) const
{ return root(new bb()); }
};
class bb: public root
{
public:
bb() { }
bb(const bb& b) {}
virtual root add(const aa& a) const
{ return root(new bb()); }
virtual root add(const bb& a) const
{ return root(new bb()); }
};
int main(int argc, char **argv)
{
}
c++ - Abstract class : invalid abstract return type for member function ‘virtual...’ - Stack Overflow