P
Patrick
Using Java I can create the following class method
public ClassA getObject()
{ ClassA result = null;
if (!vectorOfClassAObjects.isEmpty())
{ result = (ClassA)VectorOfClassAObjects.lastElement();
}
return result;
}
Where
ClassA, is a Class
vectorOfClassAObjects, is a vector of ClassA objects
and the method getObject returns the last Object in the vector, or
null if the vector is empty.
I would like to achieve the same behaviour in C++, so far I have
const ClassA& SomeClass::getObject()
{ if (!VectorOfClassAObjects.empty())
{ return VectorOfClassAObjects.back();
}
return ????;
}
What should i return if the vector is empty, is there an equivalent
NULL?
any help appreciated,
pat
public ClassA getObject()
{ ClassA result = null;
if (!vectorOfClassAObjects.isEmpty())
{ result = (ClassA)VectorOfClassAObjects.lastElement();
}
return result;
}
Where
ClassA, is a Class
vectorOfClassAObjects, is a vector of ClassA objects
and the method getObject returns the last Object in the vector, or
null if the vector is empty.
I would like to achieve the same behaviour in C++, so far I have
const ClassA& SomeClass::getObject()
{ if (!VectorOfClassAObjects.empty())
{ return VectorOfClassAObjects.back();
}
return ????;
}
What should i return if the vector is empty, is there an equivalent
NULL?
any help appreciated,
pat