Looking for Course 58 test answers and solutions? Browse our comprehensive collection of verified answers for Course 58 at courses.apriorit.com.
Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!
Is this code safe? Why?const std::string& GetGreeting(){ std::string s = "Hello"; return s;} int main(){ const std::string& ref = GetGreeting(); std::cout << ref;}Task 1There are n people entering and exiting a room. For each person i, they enter at time a and exit at time b. Implement a function that finds the maximum number of people present in the room at the same time.
For example, given [(1,5), (2,6), (3,7)]:
Task 2Roman numerals are represented by the following symbols:
| I | 1 |
| V | 5 |
| X | 10 |
| L | 50 |
| C | 100 |
| D | 500 |
| M | 1000 |
Usually a smaller value follows a larger one: VIII = 8, XII = 12. However there are 6 cases where a smaller value is placed before a larger one - in that case it is subtracted:
IV = 4, IX = 9XL = 40, XC = 90CD = 400, CM = 900Implement a function that converts a Roman numeral string to a decimal integer.
The input string is guaranteed to be a valid Roman numeral in the range [1, 3999].
#include <iostream> class A{public: virtual void Foo() { std::cout << "A::Foo"; } void Bar() { Foo(); }}; class B : public A{public: void Foo() override { std::cout << "B::Foo"; }}; int main(){ A* obj = new B(); obj->Bar(); delete obj;}Є n людей, кожна з яких входить у кімнату в момент часу a та виходить у момент часу b. Необхідно написати функцію, яка визначає максимальну кількість людей, що одночасно перебували в кімнаті.
Наприклад, для вхідних даних [(1,5), (2,6), (3,7)]:
class MyClass { /* ... */ }; MyClass a;MyClass b = a; // (1)MyClass c;c = a; // (2)class A{public: A() : m_val(42) {} private: int m_val = 10;};#include <iostream> void Foo(int n) { std::cout << "int "; }void Foo(int* p) { std::cout << "ptr "; } int main(){ Foo(NULL); // (1) Foo(nullptr); // (2)}#include <iostream> class A{public: virtual void Foo() { std::cout << "A"; }}; class B : public A{public: void Foo() override { std::cout << "B"; }}; int main(){ B b; A a = b; // ! a.Foo();}#include <iostream> void Counter(){ static int n = 0; std::cout << ++n << " ";} int main(){ Counter(); Counter(); Counter();}