View Single Post
Old 02-09-2005, 09:43 PM   #2 (permalink)
fp_unit
mike
 
Join Date: Jan 2005
Location: Ottawa, ON
Posts: 79
fp_unit is on a distinguished road
Fixed that function, alls OK now. Still, the classes are sloppy if anyone wants to improve their design an/or relationships, feel free!

Code:
void VideoStore::addMovie()
{
	numMovies++;

	movieArrayPtr = new Movie[numMovies];
	char tTitle[40];
	char tDesc[5];
	
	if(numMovies != 1)
	{
		Movie * tmpPtr = new Movie[numMovies + 1];
		cout << "In if case" << endl;
	
		// copy array, element by element
		for(int i = 0; i <= numMovies; i++)
			tmpPtr[i] = movieArrayPtr[i];
		
		delete [] movieArrayPtr;
		movieArrayPtr = tmpPtr;
	}

	cout << "Enter Movie Name: ";
	cin.getline(tTitle, 40);

	cout << "Enter DVD or VCD: ";
	cin.getline(tDesc, 5);

	// Add movie to correct location
	movieArrayPtr[numMovies - 1].setMovie(tTitle, tDesc);

}
fp_unit is offline   Reply With Quote