This is done in Listing 7 with the alloc parameter.
这是在清单7中使用alloc参数完成的。
To create a new object (in this case, the string that will be returned), first alloc the object and then initialize it.
要创建一个新对象(这里是将返回的字符串),首先分配对象,然后初始化对象。
These are not as common as instance methods, but you will often see class methods that are factory methods for creating new instances of the class; this saves you from having to alloc and initialize.
它们不像实例方法那样常见,但您将会经常看到一些类方法,它们作为创建新的类实例的工厂方法;这免得您必须进行分配和初始化。
Alloc An allocator whose value type is the same as the container's value type.
分配器,它的值类型与容器的值类型相同。
Alloc An allocator whose value type is the same as the container's value type.
分配器,它的值类型与容器的值类型相同。
应用推荐