c++ questions

zxunyynqv
timer Asked: May 25th, 2017

Question Description

Need it done before 11:45 Pm

Unformatted Attachment Preview

Note: Write (or copy/paste) your answers in this document. 1) How many objects will be created by this program? Which constructors will be called and how many times each? (2 marks) class Student { public: int id; float gpa; Student() { // initialization code here } //other members here }; class BITStudent : public Student { public: int alg_id; BITStudent() { // initialization code here } //other members here }; void main() { BITStudent imd_y2[100]; Student* p1; Student* p2 = new Student(); } 2) Library System (Console Application) (10 marks) Consider the following simple library system (code below). a) Add a User class with following members: • An int id • An array of book_id with size 8 (can borrow up to 8 books). Initially array data is set to -1 Index Value • Index Value • Index Value 0 -1 1 -1 2 -1 3 -1 4 -1 5 -1 6 -1 7 -1 A function named Borrow that adds a book id (given as parameter) to the array. For example, borrowing the books with id 5, 8 and 10 will result in: 0 5 1 8 2 10 3 -1 4 -1 5 -1 6 -1 7 -1 A function named Return that finds a book id (given as parameter) in the array and removes it. For example, following is the result of calling Return(8). Note that 8 is removed by shifting everything after it to the left. 0 5 1 10 2 -1 3 -1 4 -1 5 -1 6 -1 7 -1 • Any other member that is needed b) Modify the main() so that it • has an array for users with id values initialized to the array index (same as books). • asks for the user id as well, and borrows the book only if it is available and user has not reached maximum number of borrowed books. • saves the book information for the user class Book { public: int id; int borrower; Book() { borrower } void Borrow(int { borrower } void Return() { borrower } }; = -1; userid) = userid; = -1; void main() { Book books[50]; for (int i = 0; i < 50; i++) books[i].id = i; while (true) { int action; printf("enter 1 to borrow, 2 to return: "); scanf_s("%d", &action); int b; printf("enter book id (0-49): "); scanf_s("%d", &b); //process if (action == 1) //borrow { if (books[b].borrower == -1) { books[b].Borrow(u); } } else //return { books[b].Return(); } } } 3) Image Class: Computer Vision (Allegro Application) (10 marks) Computer Vision is the process of analyzing input images to detect, track, recognize, and react to objects. Edge Detection is a common task in computer vision where the program detects the boundary of an object. This boundary is then used to identify the shape of the object and eventually recognize the object. Consider the Imager class in Module 3. Create a new class based on Imager called Imager2 with three new functions: • • • Gray. Convert image to gray scale assuming the image is colour (RGB values are equal) BW. Convert image to black-and-white assuming image is gray (pixels turn to black if gray value less than 100, otherwise white) Edge. Detect edge points as pixels that are different from their neighbours, and then set them as black. Other pixels turn to white. Assuming the image is blackand-white.
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

This question has not been answered.

Create a free account to get help with this and any other question!

Similar Content

Related Tags

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors