Starting from:

$30

CSE165-Lab 7 Solved

1.  Create a class (e.g., myClass) that contains an array of char (e.g., char myArray[100]). Add an inline constructor that uses the Standard C library function memset() to initialize the array to the constructor argument (default this to ‘  ’) (e.g., myClass(char c = ' '){/* call memset(…) properly */}), and an inline member function called print( ) to print out all the characters in the array.

In main(), do the following: 

1)  create an object (e.g., myObj) of class myClass 

2)  call myObj.print(/* any character */) to print out all the characters in myArray. 

 

2. Create a simple class (e.g., mySimpleClass) containing an int (e.g., int x) and overload the addition operator (+) and the multiplication operator (*) as two member functions. Also provide a print( ) member function that takes an ostream& (e.g., cout) as an argument (e.g., void print(ostream& out)) and print x to that ostream& (e.g., out << x).

 

In main(), do the following: 

1)  create two objects (e.g., a and b) of class mySimpleClass. 

2)  create another object (e.g., c) of class mySimpleClass and let c = a * a + b * b. 

3)  call c.print(cout) to print x.  

More products