C++中的虛函數(virtual function)

1.簡介     虛函數是C++中用於實現多態(polymorphism)的機制。核心理念就是經過基類訪問派生類定義的函數。假設咱們有下面的類層次: class A { public:     virtual void foo() { cout << "A::foo() is called" << endl;} }; class B: public A { public:     virtual
相關文章
相關標籤/搜索