The key implementation in Stroustrup’s C with classes (C++ early form) was that the set of virtual functions in a class defines an array of pointers to functions so that the call of a virtual function is simply an indirect function call through that array.
class A
{
int a;
public:
virtual void f();
virtual void g(int);
virtual void h(double);
};
class B : public A
{
public:
int b;
void g(int); //overrides A::g()
virtual void m(B*);
};
class B is derived from class A and class A is the base class of class A
No comments:
Post a Comment