#include
using namespace std;
int main(){
class c1{
public:
int func(){
cout<<\"in the c1\";
}
When a member function is not virtual
, the function called is determined only by the type of the expression to the left of the dot (.
) or arrow (->
) operator. This is called the "static type".
When a member function is virtual
, the function called is determined by the actual most derived type of the object named by the expression left of the dot (.
) or pointed to by the expression left of the arrow (->
). This is called the "dynamic type".
Note that when a variable, member, parameter, or return type used to the left of a dot has a plain class type, the static type and dynamic type are always the same. But if a variable, member, parameter, or return type is a pointer or reference to a class type, the static type and dynamic type can be different.