假设类stringGetter只包含一个纯虚函数:重载的运算符,字符串运算符()(int x).还假设类getPageString是一个实现operator()的公共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.
Run Code Online (Sandbox Code Playgroud)
我对抽象基类有点模糊,我无法在网上找到像下面那样进行分配的好例子.我喜欢在这里询问关于这类东西的问题,因为我经常学到更多关于我甚至不打算学习的东西.我甚至无法猜测这些会导致编译器错误.任何人都可以通过交流,告诉我为什么或为什么不会导致编译错误?
| 归档时间: |
|
| 查看次数: |
178 次 |
| 最近记录: |