Code: Select all
rfbUpdateTracker.h
...
class UpdateTracker {
public:
UpdateTracker() {};
virtual ~UpdateTracker() {};
virtual void add_changed(const Region2D ®ion) = 0;
...
};
class ClippedUpdateTracker : public UpdateTracker {
public:
...
ClippedUpdateTracker(UpdateTracker &child_,
const Region2D &cliprgn_) : child(child_), cliprgn(cliprgn_) {};
virtual ~ClippedUpdateTracker() {};
virtual void add_changed(const Region2D ®ion);
...
protected:
UpdateTracker &child;
Region2D cliprgn;
};
...
rfbUpdateTracker.cpp
...
void ClippedUpdateTracker::add_changed(const Region2D ®ion) {
child.add_changed(region.intersect(cliprgn));
...
}
1:There exists a reference of SuperClass in the subclass. I guess that it provides a convenient calling for using a reference of a instantiated subclass object as the function's variable.
2:How does the functions,such as add_changed, in subclass run?That is to say, what is the calling order .The function add_changed of subclass uses the reference of superclass to generate a callling to the same function of superclass,but the superclass is an abstract class to which the calling results a calling to the function implemented in subclass.
Is it a cyclic calling?