Your premise is wrong. In C++ there is no way to "force" the implementation of a method (virtual or purely virtual) in a given class in the inheritance chain.
The only rule is that all virtual functions must have an implementation so that this class can be unstable, that is, the compile-time error you are waiting for could only happen if there is an attempt to instantiate that derived class.
Look at that:
class online{
public:
virtual void build() = 0;
};
class F : public online{
public:
F();
};
int main( void )
{
F f(); /* Tentando instanciar a classe derivada */
return 0;
}
Build error:
online.cpp: In function ‘int main()’:
online.cpp:14:4: error: invalid abstract return type for function ‘F f()’
F f();
^
online.cpp:6:7: note: because the following virtual functions are pure within ‘F’:
class F : public online{
^
online.cpp:3:22: note: virtual void online::build()
virtual void build() = 0;
I think that way F turns out to be an abstract class, doesn’t it? It tries to instantiate an object of hers. I believe that the way to "force" someone to implement the method is to try to instantiate the class.
– Giuliana Bezerra
Are you having some difficulty? Have you tried to do something different than you expected? Say what you need and you’re not being what you want. https://ideone.com/dKoYpc
– Maniero
Yes, when I created the object the compiler was in error. Thanks for the help!!
– Diego Rangel