Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Given the following Laptop class class Laptop {) private: std::string brand; int model year; public: Laptop (const std::string &brand, int modelYear) brand (brand), model
Given the following Laptop class class Laptop {) private: std::string brand; int model year; public: Laptop (const std::string &brand, int modelYear) brand (brand), model year (model Year) {) void start up() { std::cout < < "laptop + brand + (" " + std::to_string(model_year) + ") is starting up"; } }; And this function: Laptop *borrow_laptop() { Laptop *laptop loaner = new Laptop("Dell", 2021); return laptop_loaner; } Please explain the issue with the following usage and how you would fix it: int main(int argc, char **argv) { = borrow laptop(); Laptop *my_borrowed_laptop my_borrowed laptop->start_up(); Your classmate Jimmy is complaining the following code "doesn't work". He's trying to write a function to return the larger of two integers. And in the main function he's calling that function for a quick test. Your time to shine with your C++ knowledge! int max(int &a, int &b) { return (a> b) ? a b; } int main(int argc, char **argv) { int x = max(1, 2); std::cout < < x < < std::endl; What problem do you see in his code (5pt)? And how would you fix it (5pt)?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started