-
about pointers and node
Hi,
I have a program as:
Code:
Event* remove()
{
if(size>0)
{
Event* e=nodes[0];
for (int j=0; j<size-2;j++)
nodes[j]=nodes[j+1];
size=size-1;
rear=rear-1;
if( size==0) rear=-1;
return e;
}
I have some questions about this small program, when do we actually need to have a return type as pointer with the method remove?
If we have a method as :
Event* e=nodes[0];
Does this mean that we are passing an element or data from the 1st location(0) of the node to the pointer Event?
Regards,
-
It should give a pointer to the 0 element of nodes which I can only assume is an array of Event pointers. It seems like the code would benefit from a vector though.
It seems like this is probably a member of a class. I can only assume since you never declare variables and looking at how things are laid out in general. There are a few things wrong with this code as it stands. I assume this is school work so lets see if you can find them.