假设类stringGetter恰好包含一个纯虚函数:重载的参数运算符string运算符()(Int)。另外,假设类getPageString是实现stringGetter ()的公共运算符。
下列哪些C++语句肯定会导致编译器错误?
(a) stringGetter * a = new stringGetter;
(b) stringGetter * a = new getPageString;
(c) stringGetter * a;
getPageString * b = new getPageString;
a=b
(d) Exactly two of these will result in a compiler error.
(e) It is possible that none of these will result in a compiler error.我对抽象基类有点模糊,而且我在网上找不到像下面这样做任务的好例子。我喜欢在这里问一些关于这类东西的问题,因为我经常会学到更多我甚至不打算学的东西。我甚至不能猜测其中哪一个会导致编译器错误。有没有人可以通过a-c来告诉我为什么它会导致编译器错误?
发布于 2011-02-22 05:38:39
你不能有抽象类的实例,这就排除了(a)。选项(c)只是做(b)的一种更困难的方式。
https://stackoverflow.com/questions/5071482
复制相似问题