//----------------------------------------------------------------- // Author: Zhixiang Chen // Class: CSCI/CMPE 2380, Spring 2009 // Lab 4: Class template practice // Date: January 13, 2009 // Comment: The code here is meant to be revised. // //----------------------------------------------------------------- // // This lab exercise is practice class template declaration and implementation // // Compile and run your program. When everything is fine, // print your .cpp and .h files and turn them to me or the TA. // ***************************************************************** #include < iostream > #include #include < string > #include < cstring > #include < cmath> #include #include #include "lab2380_4_head.h" using namespace std; int main() { /************************************************************************ * Part One: class object creation, class pointers, member calling, etc. ************************************************************************/ int y; valueType x; cout<<"get vaue for x "< " << y < cat; nameType dog("What", "Wow"); cat.setValue(dog); nameType rat; cat.getValue(rat); cout<<"rat is => " << rat < "; cat.printValue(); /************************************************************************************* * Part Two: For you to complete (1) Use the bookType class you have implemented in lab2380_3 to create a valeType objects. Do some exercises as shown in Part One. ************************************************************************************/ /************************************************************************************* * Part Three: For you to complete (1) Implement a blackHole class template with two parameters template The class shall have two data members: a. type element[maxSize] b. int currentSize The class shall include at least two basic method: void getIntoHole (type & x): this first check if the blackHole is full or not. If not, it then adds x into the element array of the backHole. type getOutHole(): this first checks if the blackHole is empty or not. If not, it then deletes one random element from the element array and returns the deleted elements and decrements the currentSize by one. (2) Use this template to create an int blackHole and a string blackHole. Do some practice about these two blackHoles such geting out of the hole and getting into the hole, etc. ************************************************************************************/ //complete the program return 0; }