Lab 5 Course: CSE165 Solved

40.00 $

Category: Tags: , , , ,
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: zip solution files instantly, after Payment

Securely Powered by: Secure Checkout

Description

5/5 - (1 vote)

All the exercises below are selected from the textbook: Thinking in C++ (volume 1).   An output example is attached to each problem, of which the main goal is to give you a better sense of what a typical  output  looks  like.  So,  there  is  no  need  to  exactly  follow  the  provided  output. Feel  free  to  make  an  adjustment  accordingly. I told the TAs that we’re very flexible and fine with any reasonable output.

1. [Exercise 1 on Page 610] Create a class Counted that contains an int id and a static int count. The default constructor  should begin: Counted() : id(count++). It should also print its id and that it’s being created. The destructor should print  that it’s being destroyed and its id. Test your class. [35 pts]

Output example:   In the constructor, cout << “An object is being created is created, id: ”<< id << endl;  In the destructor, cout << “ The created object is being destroyed, id: ” << id << endl;

2. [Exercise 4 on Page 610] Create a vector< Counted*> and fill it with pointers to new Counted objects (from Exercise  1). Move through the vector and print the Counted objects, then move through again and delete each one. [30 pts]

Output example:   In the constructor, cout << “An object is being created is created, id: ”<< id << endl;  In the destructor, cout << “ The created object is being destroyed, id: ” << id << endl;  [Optional] In the main(), print each created object’s id.

3. [Exercise-14 on Page 718] In AddingVirtuals.cpp, make all the member functions of Pet pure virtual, but provide  a definition for name(). Fix Dog as necessary, using the base-class definition of name(). [35 points]

Output example:   int main() {

Pet* p = new Dog(placeholder); // replace the placeholder with any name you’d like  cout << p->speak();  delete p;

return 0;

}

Requirements:

* Usage of spaces, blank lines, indention, and comments for readability.

* Descriptive names of variables, functions, structs, classes, and objects (if any).

* Appropriate usage of structs, classes, and objects (if any).

Penalties:

* Zero if you have possession of a copy of online solutions or work done by someone else.

* 5-point deduction per day late

 

  • Lab-5-zr0kfy.zip