cocos2dx c++ 将向量附加到向量
cocos2dx c++ appending a vector to a vector
如何连接两个 cocos2d::Vector ?
cocos2d::Vector<FiniteTimeAction*> V1;
cocos2d::Vector<FiniteTimeAction*> V2;
我想将 V2 附加到 V1;
cocos2d::Vector 已重载 pushBack,它接受一个向量并将其推回另一个向量。
V1.pushBack(V2);
CCVector.h
/** Adds a new element at the end of the Vector. */
void pushBack(T object)
{
CCASSERT(object != nullptr, "The object should not be nullptr");
_data.push_back( object );
object->retain();
}
/** Push all elements of an existing Vector to the end of current Vector. */
void pushBack(const Vector<T>& other)
{
for(const auto &obj : other) {
_data.push_back(obj);
obj->retain();
}
}
P.S 不清楚为什么他们不在重载的 pushBack(const Vector& other) 中重新使用 pushBack(T object)
如何连接两个 cocos2d::Vector ?
cocos2d::Vector<FiniteTimeAction*> V1;
cocos2d::Vector<FiniteTimeAction*> V2;
我想将 V2 附加到 V1;
cocos2d::Vector 已重载 pushBack,它接受一个向量并将其推回另一个向量。
V1.pushBack(V2);
CCVector.h
/** Adds a new element at the end of the Vector. */
void pushBack(T object)
{
CCASSERT(object != nullptr, "The object should not be nullptr");
_data.push_back( object );
object->retain();
}
/** Push all elements of an existing Vector to the end of current Vector. */
void pushBack(const Vector<T>& other)
{
for(const auto &obj : other) {
_data.push_back(obj);
obj->retain();
}
}
P.S 不清楚为什么他们不在重载的 pushBack(const Vector& other) 中重新使用 pushBack(T object)