Allow derived class to implement a single pure virtual function from base abstract class?

No, that's not possible. What if you called T operator()(U) on a Test and it hadn't implemented it? You'll have to eventually have a class implement all of them (or inherit from one or more classes that implement each of them) to instantiate it.

No, that's not possible. What if you called T operator()(U) on a Test* and it hadn't implemented it? You'll have to eventually have a class implement all of them (or inherit from one or more classes that implement each of them) to instantiate it.

You can leave any number of virtual functions undefined, but if you do, your class won't be instantiatable because it's still abstract. You'll have to have another class inherit from it and define those undefined functions and instantiate that. Tl;dr: To instantiate a class, somewhere in its class hierarchy all virtual functions must have a definition.

I was hoping that if the derived class only implemented one of the functions, the others would be considered undefined for that class. – ProtoSphere Aug 28 at 3:34 @Protosphere that wouldn't be good, because you can pass around Test*s as Functor*s. So you can't tell what type it is, and the compiler can't follow your classes around at compile time and make sure you don't call an undefined virtual method on a class instance which hasn't defined it.So you have to implement all of them.

– Seth Carnegie Aug 28 at 3:36 So I guess the only way to achieve the behaviour that I want would be to have separate base classes such as Functor0, Functor1, Functor2 etc. That declare an operator() with a set amount of arguments. – ProtoSphere Aug 28 at 3:39 @Proto yes, that's correct. Then you know how many arguments your Functor takes when you accept it as an argument.

One possibility is to declare a template class Functor; and write specializations for 1, 2, 3, 4, 5, etc arguments, then have those take their respective numbers of arguments to operator(). – Seth Carnegie Aug 28 at 3:46 @Proto like this, or you could always deduce the number of parameters by the number of template type arguments like this – Seth Carnegie Aug 28 at 3:54.

Yes, it's possible. But the derived class will still be abstract.

Yes, that's possible. However, that means that the derived class itself is still abstract and cannot be instantiated, and you need to derive further from it until you've defined all the virtual functions.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions