In a part to one of our assignments we were to use an array (that represents classes) and the user needs to be able to pick..lets say..Classes[3] and get rid of it. But if the array is holding 8 spots, the program needs to be able to pick it out of the middle and get rid of it. And shift any following data over to the previous element.

*in basic terms, because i don't feel it's necessary to show all struct's i had before, and previously they were able to tell you how many classes they had.*

cout<<"Which class would you like to get rid of?"<<endl;
cin>>I;
I--;
for(I= ;I<Classes.length()-1;I++)
      ??

and this is where i get caught thinking of a for loop to adjust to the size. And I've been informed that a bubble sort isn't necessary.

for the for loop replace I with C. sorry about that.

1. Next time use code tag with the language specifier:
[code=cplusplus] source(s)

[/code]
2. An array in C++ is not a class. No such beast as array.length() member function.
An array is a fixed size data structure. You can't resize an array. However you can dynamically allocate a memory for n elements and get a pointer to this memory:

int n;
// initialize n (for example, get the value from the console)
...
Class* array = new Class[n];
Now you have a pointer to n Class elements (array).
// Don't forget to free this memory:
delete [] array;

To resize this array:

Class* newarray = new Class[newn];
// Move min(n,newn) elements from old array to newarray:
...
delete [] array;  // free old array
array = newarray; // now array points to the new array
n = newn;         // now n is a new array size

If you can't understand these instructions then you must reread your textbook again and again ;)...

hmm, interesting, maybe it's just our library, but we have code in there that works such as:

Array.length() where if it's 8 units long (0-7) than the value 8 is put in place.

Also code like Array.resize(n) where n is now the new size of the array.
Sorry i wasn't aware that it might just be our library or compiler. I'm still a first year programmer, so i'm not too sure about how other programming out side of class works, pretty much the reason i joined the forums.

Well, you have a class named Array. May be it has a member function named length. But the C++ language has (in your class, on this forum and all over the World) array data structure (see my pst above ;)). Your class Array is not a part of C++ standard library. Everybody can write his/her own class Array. Have you every heard about my classes named Array (I have wrote 10 or more ;))? It's safe to say that they were very useful classes (for me and my coworkers). However you can't use these classes without docs or sources.

Next time try to present more info about non-standard elements of your program environment. After all, you are studying the C++ programming language, not your school programming slang...

Apropos, there is a wonderful standard class template std::vector in C++ language:

typedef std::vector<Class> Array;
...
Array classes(8);
cout << classes.size() << endl; // prints 8
...
classes.resize(20);
...
classes.erase(ith);
// and much more...
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.