Ref: Interview: Can we instantiate abstract class?

事實上,這個標題是有問題的。不過為了方便搜尋起見,所以還是這樣保留。

為什麼會說有問題呢?因為 abstract class 不能被 instantiate

You can't instantiate your abstract class, however you can instantiate a concrete subclass of your abstract class.

My my = my() {};   // 這樣是 anonymous implementation

My my = my();       // 這樣才是 instantiate 

Comments

comments powered by Disqus
Copyright © 2013 Andro Chen
Powered by Logdown and Greyshade
Favicon from The Noun Project