#include<iostream.h>
class Window // Base class for C++ virtual function example
{
public:
virtual void Create(int a) // virtual function for C++ virtual function example
{
cout <<"Base class Window"<<a;
}
};
class CommandButton : public Window
{
public:
void Create()
{
cout<<"Derived class Command Button - Overridden C++ virtual function";
}
void Create(int a, int b)
{
cout<<"Derived class Command Button - a and b"<<a<<b;
}
};
void main()
{
Window *x, *y;
// x = new Window();
// x->Create();
//y = new CommandButton();
//y->Create(10);
CommandButton *cb;
cb=new CommandButton();
cb->Create();
cb->Create(140,2);
}
class Window // Base class for C++ virtual function example
{
public:
virtual void Create(int a) // virtual function for C++ virtual function example
{
cout <<"Base class Window"<<a;
}
};
class CommandButton : public Window
{
public:
void Create()
{
cout<<"Derived class Command Button - Overridden C++ virtual function";
}
void Create(int a, int b)
{
cout<<"Derived class Command Button - a and b"<<a<<b;
}
};
void main()
{
Window *x, *y;
// x = new Window();
// x->Create();
//y = new CommandButton();
//y->Create(10);
CommandButton *cb;
cb=new CommandButton();
cb->Create();
cb->Create(140,2);
}
No comments:
Post a Comment