问题描述
我正在阅读GoF书,在原型部分的开头我读到:
I was reading the GoF book and in the beginning of the prototype section I read this:
我从来没有使用过C ++我对OO编程有一个非常好的了解,但是对我来说这并没有任何意义。任何人都可以在这里详细说明(我已经使用了C,Python,Java,SQL,如果这有帮助的话)。
I've never used C++ but I do have a pretty good understanding of OO programming, yet, this doesn't really make any sense to me. Can anyone out there elaborate on this (I have used\use: C, Python, Java, SQL if that helps.)
推荐答案
p>为了使一个类成为第一类对象,该语言需要支持执行诸如允许函数将类(而不是实例)作为参数的操作,能够在容器中容纳类,并能够从函数返回类。
For a class to be a first class object, the language needs to support doing things like allowing functions to take classes (not instances) as parameters, be able to hold classes in containers, and be able to return classes from functions.
对于具有第一类类的语言的示例,请考虑Java。任何对象都是其类的实例。该类本身就是。
For an example of a language with first class classes, consider Java. Any object is an instance of its class. That class is itself an instance of java.lang.Class.
这篇关于将类作为一级对象进行处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!