Pregunta

I'm having trouble understanding what an internal array means. I have an assignment that ask to implement a standard queue class using internal array and set the array to 12. Is internal array another word for dynamic array, static array, ...? What is internal array? Also, what is a fixed size array inside object. This is on c++.

I thought is was asking to use a static array, fixed size array and pass by reference. As they are many ways to write a queue, just not sure which one does internal array falls under

cont int capacity = 12;
typeddef int element;
class Queue
{
public:
...
void add(const element &value);
private:
...
element myArray[capacity];
}

Now I'm being told by a classmate that it means a fixed size array inside object.

¿Fue útil?

Solución

public class StandardQueue
{
    private Array _array = new Array();  // This is the encapsulated member

    public void WorkWithArray()
    {
        // Work with the array here
    }
}

In this example the member called _array is only accessible from within the class StandardQueue. This means that if you create an instance of StandardQueue you would be able toa ccess function WorkWithArray but not _array. All access to _array must happen from within the class (e.g. inside the functions).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top