title-img


Box It! C++

Design a class named Box whose dimensions are integers and private to the class. The dimensions are labelled: length l, breadth b , and height h. The default constructor of the class should initialize, l , b and h to 0. The parameterized constructor Box(int length, int breadth, int height) should initialize Box's l, b and h to length, breadth and height. The copy constructor Box(Box B ) should set l, b and h to B 's l, b and h, respectively. Apart from the above, the class should h

View Solution →

Inherited Code C++

You inherited a piece of code that performs username validation for your company's website. The existing function works reasonably well, but it throws an exception when the username is too short. Upon review, you realize that nobody ever defined the exception. The inherited code is provided for you in the locked section of your editor. Complete the code so that, when an exception is thrown, it prints Too short: n (where n is the length of the given username). Input Format The first line

View Solution →

Exceptional Server C++

In this challenge, you are required to handle error messages while working with small computational server that performs complex calculations. It has a function that takes 2 large numbers as its input and returns a numeric result. Unfortunately, there are various exceptions that may occur during execution. Complete the code in your editor so that it prints appropriate error messages, should anything go wrong. The expected behavior is defined as follows: If the compute function runs fi

View Solution →

Virtual Functions C++

This problem is to get you familiar with virtual functions. Create three classes Person, Professor and Student. The class Person should have data members name and age. The classes Professor and Student should inherit from the class Person. The class Professor should have two integer members: publications and cur_id. There will be two member functions: getdata and putdata. The function getdata should get the input from the user: the name, age and publications of the professor. The function put

View Solution →

Abstract Classes - Polymorphism C++

Abstract base classes in C++ can only be used as base classes. Thus, they are allowed to have virtual member functions without definitions. A cache is a component that stores data so future requests for that data can be served faster. The data stored in a cache might be the results of an earlier computation, or the duplicates of data stored elsewhere. A cache hit occurs when the requested data can be found in a cache, while a cache miss occurs when it cannot. Cache hits are served by reading

View Solution →