C ++中抽象类和纯抽象类之间有什么区别? [英] What is the difference between abstract class and pure abstract class in C++?

查看:357
本文介绍了C ++中抽象类和纯抽象类之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在标题中问我的主要问题。我不重复。 (DRY:D)

I asked my main question in the title. I don't repeat it. (DRY :D)

编辑:示例:


迭代器是纯抽象:任何类似于
迭代器的东西都是迭代器。

Iterators are pure abstractions: Anything that behaves like an iterator is an iterator.

这是什么意思?

推荐答案

抽象类至少有一个纯虚函数。这是标准的C ++术语。

An abstract class has at least one pure virtual function. This is standard C++ terminology.

有些人使用纯抽象类这个术语来描述一个只有纯虚函数的类字,没有数据成员,没有具体的功能)。这相当于Java接口。

Some people use the term pure abstract class to describe a class that has nothing but pure virtual functions (in other words, no data members and no concrete functions). This is equivalent to Java interfaces.

现在到您的实际问题:


迭代器是纯抽象的:任何行为类似迭代器的东西都是迭代器。

Iterators are pure abstractions: Anything that behaves like an iterator is an iterator.

这与抽象类无关)。它所说的是,任何满足迭代器契约是一个迭代器。它甚至不必是一个类(认为指针)。

This has nothing to do with abstract classes (pure or otherwise). All it's saying is that anything that fulfils the iterator contract is an iterator. It doesn't even have to be a class (think pointers).

这篇关于C ++中抽象类和纯抽象类之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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