#include <cstdio>
#include <assert.h>
class Shit
{
public:
friend class ShitFactory;
operator const char*() { return "A shit shitted by some shitty shit"; }
Shit* merge(Shit*) { return this; }
};
class ShitFactory
{
public:
static Shit* createRegularShit() { return NULL; }
static Shit* createStinkShit() { return NULL; }
static Shit* createPrettyShit() { return NULL; }
};
class Shitable
{
public:
virtual Shit* shit() = 0;
virtual void eatShit(Shit* shit) = 0;
};
class Human : public Shitable
{
public:
virtual ~Human() { }
Shit* shit() { return ShitFactory::createRegularShit(); }
void eatShit(Shit* shit) { assert(false); }
};
class Loli : public Human
{
public:
Shit* shit() { return ShitFactory::createPrettyShit(); }
void eatShit(Shit* shit) { printf("%s! WARNING: Zhen Xiang!\n", static_cast<const char*>(*shit)); }
};
int main()
{
Loli* loli = new Loli;
Shit* shit = Human().shit()->merge(loli->shit());
loli->eatShit(shit);
delete shit;
delete loli;
return 0;
}
#include <assert.h>
class Shit
{
public:
friend class ShitFactory;
operator const char*() { return "A shit shitted by some shitty shit"; }
Shit* merge(Shit*) { return this; }
};
class ShitFactory
{
public:
static Shit* createRegularShit() { return NULL; }
static Shit* createStinkShit() { return NULL; }
static Shit* createPrettyShit() { return NULL; }
};
class Shitable
{
public:
virtual Shit* shit() = 0;
virtual void eatShit(Shit* shit) = 0;
};
class Human : public Shitable
{
public:
virtual ~Human() { }
Shit* shit() { return ShitFactory::createRegularShit(); }
void eatShit(Shit* shit) { assert(false); }
};
class Loli : public Human
{
public:
Shit* shit() { return ShitFactory::createPrettyShit(); }
void eatShit(Shit* shit) { printf("%s! WARNING: Zhen Xiang!\n", static_cast<const char*>(*shit)); }
};
int main()
{
Loli* loli = new Loli;
Shit* shit = Human().shit()->merge(loli->shit());
loli->eatShit(shit);
delete shit;
delete loli;
return 0;
}