How do i make an array class that contains pointers to objects? (in this case, object of type travel.) right now all i got is array of object, not pointer......
class Array
{
public:
Array();
Array(int size);
Array(const Array & anArray);
~Array();
friend ostream& operator<< (ostream& out, const Array & anArray);
const Array & operator = (const Array & anArray);
int getSize (void)const;
void setElem (int index, const travel & aTrip);
travel & getElem (int index) const;
private:
travel * travelArray;
int size;
};
Array::Array()
{
travelArray = new travel[1];
size = 0;
}
void Array::setElem(int index, const travel &aTrip)
{
if (index >= 0 && index <= size)
{
travelArray[index] = aTrip;
}
else
cout <<"INVALID INDEX"<<endl;
}
i'm thinking
private:
{
travel ** travelArray;
.......
Am I even close?
thanks