//----------------------------------------------------------------- // Author: Zhixiang Chen // Class: CSCI/CMPE 2380, Spring 2009 // Lab 3: Simple excercises about classes // Date: January 13, 2009 // Comment: The code here is meant to be revised. // //----------------------------------------------------------------- // // This lab exercise is practice class 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_3_head.h" using namespace std; int main() { /************************************************************************ * Part One: class object creation, class pointers, member calling, etc. ************************************************************************/ //create nameType objects nameType cat; //use default constructor nameType dog("Tom", "Jerry"); //use another constructor nameType rat(dog); //use copy constructor cin>>cat; //use overloaded >> to get cat cout<<"cat's name is => " < "; printName(dog); //use friend function printName to print dog cout<<"rat's name is => "; printName(rat); //use friend function printName to print rat rat = cat; //use overloaded = cout<<"rat's name now is => " <>*ptr; cout<<"the name of *ptr is => " <<*ptr; ptr->setName("Blabla", "Wow"); cout<<"the name of *ptr is now => "; printName(*ptr); /************************************************************************************* * Part Two: For you to complete (1) Declare a bookType class with at least the following data members: bookTile, ISBN, Author, price, etc. (2) Declare a similar set of methods like those in nameType (3) Add the declarations and implementation in the head file "lab2380_3_b_head.h" (4) Include this header file in "lab2380_3.cpp and carry out similar tests as in Part One. ************************************************************************************/ //complete the program return 0; }