title-img


Accessing Inherited Functions C++

You are given three classes A, B and C. All three classes implement their own version of func. In class A, func multiplies the value passed as a parameter by 2 : class A { public: A(){ callA = 0; } private: int callA; void inc(){ callA++; } protected: void func(int & a) { a = a * 2; inc(); } public: int getA(){ return callA

View Solution →

Magic Spells C++

While playing a video game, you are battling a powerful dark wizard. He casts his spells from a distance, giving you only a few seconds to react and conjure your counterspells. For a counterspell to be effective, you must first identify what kind of spell you are dealing with. The wizard uses scrolls to conjure his spells, and sometimes he uses some of his generic spells that restore his stamina. In that case, you will be able to extract the name of the scroll from the spell. Then you need to

View Solution →

Hotel Prices C++

In this challenge, the task is to debug the existing code to successfully execute all provided test files. The given code defines two classes HotelRoom and HotelApartment denoting respectively a standard hotel room and a hotel apartment. An instance of any of these classes has two parameters: bedrooms and bathrooms denoting respectively the number of bedrooms and the number of bathrooms in the room. The prices of a standard hotel room and hotel apartment are given as: Hotel Room: 5

View Solution →

Cpp exception handling C++

In this challenge, the task is to debug the existing code to successfully execute all provided test files. You are required to extend the existing code so that it handles std::invalid_argument exception properly. More specifically, you have to extend the implementation of process_input function. It takes integer n as an argument and has to work as follows: 1. It calls function largest_proper_divisor(n). 2. If this call returns a value without raising an exception, it should print in

View Solution →

Overloading Ostream Operator C++

The task is to overload the << operator for Person class in such a way that for p being an instance of class Person the result of: std::cout << p << " " << <some_string_value> << std::endl; produces the following output: first_name=<first_name>,last_name=<last_name> <some_string_value> where: <first_name> is the value of p's first_name_ <last_name> is the value of p's last_name_ <some_string_value> is an arbitrary std::string value Input Format The input is rea

View Solution →