关于“不能实例化抽象类”的更多信息 [英] More information on "cannot instantiate abstract class"

查看:187
本文介绍了关于“不能实例化抽象类”的更多信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时我使用相对复杂的(有时令人困惑的 - 他们由原来编写的人的方式)抽象类。当继承它时,我有时会遇到不能实例化抽象类,并且大部分时间是因为我忘了声明&实现纯虚函数。我可以从编译器获得更多的信息,它发现我没有实现,而不是寻找它的函数?

Sometimes I am working with relatively complex (and sometimes confusing - with the way they are laid out by whoever wrote it originally) abstract classes. When inheriting from it, I sometimes encounter cannot instantiate abstract class and most of the time it is because I forgot to declare & implement a pure virtual function. Can I get more information from the compiler about which function it found I did not implement instead of hunting for it?

推荐答案

使用Visual Studio?如果是,请从错误列表选项卡切换到输出选项卡。将会有类似:

Are you using Visual Studio? If so, then switch from Error List tab to Output tab. There will be something like:

main.cpp(8): error C2259: 'foo' : cannot instantiate abstract class
          due to following members:
          'void Foo::method(char)' : is abstract

这篇关于关于“不能实例化抽象类”的更多信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆