C
coolchap
Hi,
I have a query regarding the front() function in list. Lets say
that I have a list of pointers
list <ptr *> aListofPtrs;
Size of aListPtrs is zero
now i get the first element... and call a function in the class ptr..
lets say getSomething()
aListofPtrs.front()->getSomething()
As for me, this should return a nullpointer exception, But instead the
program was compiled and ran too.. getSomething() returned an arbitary
value.
I just want to understand how the front() method works in case the
list has zero elements and we call the front() method.
Regards,
Prashant
I have a query regarding the front() function in list. Lets say
that I have a list of pointers
list <ptr *> aListofPtrs;
Size of aListPtrs is zero
now i get the first element... and call a function in the class ptr..
lets say getSomething()
aListofPtrs.front()->getSomething()
As for me, this should return a nullpointer exception, But instead the
program was compiled and ran too.. getSomething() returned an arbitary
value.
I just want to understand how the front() method works in case the
list has zero elements and we call the front() method.
Regards,
Prashant