示例#1
0
/**************************************************************************
	parameters: Painting *
	return value: -

	Copy constructor. Preforms a deep copy on a Painting. Appends "_COPY"
	to the title to denote that it is a copy.
	
**************************************************************************/
Painting::Painting(Painting& p)
{
	ostringstream convert;
	Painting::creationCounter = Painting::creationCounter + 1;
	height = p.getHeight();
	width = p.getWidth();
	id = Painting::creationCounter;
	convert << Painting::creationCounter;
	title = p.getTitle() + "_COPY" + convert.str();
    	next = NULL;
}
示例#2
0
/*	Change:
 *	- Global for loop variable instantiations
 *	- See below for others
 */
int main()
{
	// Changed number of records, only 4
	const int NUM = 4;
	
	// Declare new paintings
	Painting pictures[NUM];

    for(int i = 0; i < NUM; ++i)
    {
		// Declare new instance
		Painting temp;
		
		// Set the data
		temp.setData();
		
		// Check if it is famous (to increase cost)
		if(isPaintingFamous(temp))
		{
			// Create a Famous painting
			FamousPainting tempFamous(temp.getTitle(), temp.getArtist());
			
			// Copy to the temporary class, default contructor should be fine
			temp = tempFamous;
		}
		
		// Added array index
       pictures[i] = temp;
	}
	
	// Cleaned up for loop
	for (int i = 0; i < NUM; i++)
		// Added index
		pictures[i].showPainting();
	
	// Return for main function
	return 0;
}