Exemplo n.º 1
0
void TestPart2(){
	
	Chain<string> a, b;
	
	a.ReadChain(); // User provides input for Chain a.
	cout <<"A: "<< a <<endl;
	cout <<"A.size: "<< a.Size()<<endl;
	
	b.ReadChain(); // User provides input for Chain b. 
	cout <<"B: "<< b << endl;
	cout <<"B.size: "<< b.Size()<<endl;
	
	cout <<"A+B: "<<a + b << endl; // Concatenates the two Chains.
	Chain<string> d = a + b; 
	cout <<"D: "<< d << endl;
	cout <<"D.size: "<< d.Size()<<endl;

	cout <<"D+: "<< d + "hi_there" <<endl; // Adds an element to the end.
	cout <<"D+.size: "<< d.Size()<<endl;
	cout <<"A[2]: "<< a[2] << endl; 	// Should print the 3rd element.
							// Throw an exception (or even abort()) if is out of
							// range.
	b[1] = "b_string"; // Should change the 2nd element to “b_string”
	cout <<"B: "<< b << endl;
	b[0] = "a_string"; 
	cout <<"B: "<< b <<endl;
	cout <<"B.size: "<< b.Size()<<endl;

} // End of TestPart2