0

I'm a little confused about the terms "static type" and "dynamic type".

Given

class A {};
class B:A {};

A* a = new B();
B* b = new B();

The static type of *a is B and the dynamic type is A. The static type of *b is B and the dynamic type is B.

Is that correct?

This is not a question about dynamic type checking but rather the terms "static type" and "dynamic type". In this article http://makomdev.blogspot.com/2008/04/c-static-types-vs-dynamic-types.html the author defines static type as the "real" type and dynamic type as the base type. He also defines them in terms of rhs and lhs which seems contradictory.

Richard Johnson
  • 612
  • 1
  • 9
  • 20
  • did you mean the type of `*a` ? – Karoly Horvath May 15 '13 at 17:37
  • I'm not asking about dynamic type checking but rather the terms "static type" and "dynamic type". In this article http://makomdev.blogspot.com/2008/04/c-static-types-vs-dynamic-types.html this guy defines static type as the "real" type and dynamic type as the base type. He also talks about them in terms of rhs and lhs which seems contradictory. – Richard Johnson May 15 '13 at 17:40
  • I just added an answer to the "duplicate" question: http://stackoverflow.com/a/16571767/37386 – user9876 May 15 '13 at 17:51

0 Answers0