Is it a good idea to make interfaces like
class Foo
{
void bar()
{
assert(false); //Not implemented in derieved class, go fix nao.
}
}
class Derieved : public bar
{
void bar()
{
print("yay");
}
}
to have some idea what methods a class should have, when i need some common functionality for the classes to be used as template args?
One problem i see is that it wont fail at compile time if something is not implemented. Is there a way to do something like this, so that a compile time failure would result if something is missing and the base class version is called instead (which will fail at runtime due to the assert)?
An obvious solution is to simply comment out the ": public bar" section.
Or do you recommend just creating some documentation in a place well hidden somewhere with outdated information as to what methods/typedefs a class should implement to be a 'valid' value for certain templates?