All pastes #382298 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-03-05 14:42 UTC
rendered paste body
#include <stdio.h>

class Element {
public:
	virtual const char* name() const = 0;
};

class ElementAccess {
public:
#if 0
	virtual Element* element() {
		return NULL;
	}
#else
	virtual Element* element() = 0;
#endif
};

class ISink : public ElementAccess {
public:
	ISink() {
		peng();
	}
	
	virtual ~ISink() {
		peng();
	}
	
	void peng() {
		printf(element()->name());
	}
};

class Sink : public Element, public ISink {
public:
	Sink() {
	}
	
	Element* element() {
		return this;
	}
	
	const char* name() const {
		return "Sink";
	}
};

int main() {
	Sink* sink = new Sink;
}