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

yes. You'll be using travel ** travelArray That said, your assignment line will of course be travelArray[index] = &aTrip; I noticed you check if index <= size. If the array declared has size elements, this will be a problem; if the array declared has size+1 elements, then it is not a problem.

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.