Nor this class nor mat has any virtual methods. Once matrix is created it will be automatically managed by using reference counting mechanism. Thus references or pointers to these two classes can be freely but carefully converted one to another.