In the class:
private:
value_type *data;
size_type used;
size_type capacity;
size_type current_index;
------
sequence::sequence(const sequence& entry)
{
data = new value_type[entry.capacity];
/* copy constructor ensures that the new object will have its own dynamically allocated memory */
used = entry.used;
current_index = entry.current_index;
}/* end of copy construct
The program is buggy and when I run it it give me garbage when prompted to display. I've to make copies since it's a copy constructor; however, I know I'm missing something, but can't figure it out.
I might be over looking it or may be not looking at it all.
Could you please assist me what is going on, and what needs to fixed. Thanks!
That for loop is ill formed and will not run at all.
It also would not even compile, because this is a pointer and not an object, therefore you can't use the dot operator with it.
If there's a bug in the code, we're not going to see it if you don't post the actual bugged code. If you retype the code that doesn't tell us anything because you may have fixed/introduced bugs in the retype.