popBack and popFront

P

pleatofthepants

I could use some help. I am writting two functions, one is popBack and
one is popFront.

popFront needs to remove a data element from the front of my data
structure.
popFront (T& n)
{

}
popBack needs to remove a data element from the rear of my data
structure
popBack (T& n)
{

}

I have two functions shiftRight and shiftLeft that will move the
elements in the array right or left.

void shiftRight()
{
//decrement this iteration
for (int i = size; i >= 0; i--)
{
data = data[i - 1];
}
size++;
}
void shiftLeft ()
{
for (int i = 0; i < size; i++)
{
data = data[i + 1];
}
size--;
}
 
E

Erik Wikström

I could use some help. I am writting two functions, one is popBack and
one is popFront.

popFront needs to remove a data element from the front of my data
structure.
popFront (T& n)
{

}
popBack needs to remove a data element from the rear of my data
structure
popBack (T& n)
{

}

I have two functions shiftRight and shiftLeft that will move the
elements in the array right or left.

void shiftRight()
{
//decrement this iteration
for (int i = size; i >= 0; i--)
{
data = data[i - 1];
}
size++;
}
void shiftLeft ()
{
for (int i = 0; i < size; i++)
{
data = data[i + 1];
}
size--;
}


OK, and?

Take a look in the FAQ, http://www.parashift.com/c++-faq-lite/,
especially sections 5.2 and 5.8.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,199
Latest member
AnyaFlynn6

Latest Threads

Top