It's pure virtual function (or abstract function) that has no body at all! A pure virtual function simply acts as a placeholder that is meant to be redefined by derived classes.
To create a pure virtual function, rather than define a body for the function, we simply assign the function the value 0. so, by doing equal to zero we are giving definition of that virtual function.
struct MyX
{
virtualvoid MyX_func() = 0; //make struct MyX an abstract class
};
//have to seperately define a body for
//the function if you want to.
void MyX::MyX_func()
{
}
struct MyX_D :MyX //a derived class
{
void MyX_func() override
{
MyX::MyX_func();
}
};
int main()
{
MyX *pm = new MyX_D;
pm->MyX_func();
}
In the above example, I have given two arguments to the function myfunc. So, when I define the function, can i have different number of arguments to this function?