Question

I need help with this question. Please answer it in full sentences and neat for me...

I need help with this question. Please answer it in full sentences and neat for me to understand. Thank you.

1. What does the following code print out? Give the exact answer.

#include <iostream>

using namespace std;
class Cellphone

{

public:

                virtual void features() {

                                cout << "Loading cellphone features.\n";

                }

};

class App: public Cellphone{

public:

                void features() {

                                cout << "Loading app features.\n";

                }

};

class Driver: public Cellphone{

public:

                void features()      {

                                cout << "Loading driver features.\n";

                }

};

class Loader {

public:

                void loadFeatures(Cellphone *cphone) {

                                cphone->features()
                }

};

int main() {

                Loader *l = new Loader;

                Cellphone *w;

                App b;

                Driver g;

                w = &b;

                l->loadFeatures(w);

                w = &g;

                l->loadFeatures(w);

                return 0;

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Thank you. .. ..

Add a comment
Know the answer?
Add Answer to:
I need help with this question. Please answer it in full sentences and neat for me...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Greetings, everybody I already started working in this program. I just need someone to help me...

    Greetings, everybody I already started working in this program. I just need someone to help me complete this part of the assignment (my program has 4 parts of code: main.cpp; Student.cpp; Student.h; StudentGrades.cpp; StudentGrades.h) Just Modify only the StudentGrades.h and StudentGrades.cpp files to correct all defect you will need to provide implementation for the copy constructor, assignment operator, and destructor for the StudentGrades class. Here are my files: (1) Main.cpp #include <iostream> #include <string> #include "StudentGrades.h" using namespace std; int...

  • Given the following code: #include <iostream> #include <iomanip> using namespace std; class Animal{ private: int height;...

    Given the following code: #include <iostream> #include <iomanip> using namespace std; class Animal{ private: int height; int weight; public: void setHeight(int h){ height = h; } int getHeight(){ return height; } void setWeight(int w){ weight = w; } int getWeight(){ return weight; } virtual void makeSound() = 0; virtual void eat(); }; class Dog: public Animal{ public: void makeSound(){ cout << "Bow Bow\n"; } void eat (){ cout <<"The dog is eating\n"; } void Catch(){ cout << "The dog is...

  • C++ Please complete the implementation of the following source code (Question3.cpp). You need to add your...

    C++ Please complete the implementation of the following source code (Question3.cpp). You need to add your code in the source code where the comment “// your code” locates. After you finish the implementation, please also provide the output of your program. #include <iostream> using namespace std; class Shape { protected: // your code public: void setWidth (int w) { // your code } void setHeight (int h) { // your code } }; class Rectangle: public Shape { public: int...

  • Need help with a multiple inheritance work Question Compile and run the file. If you find...

    Need help with a multiple inheritance work Question Compile and run the file. If you find any compilation errors,explain their reason as comments in the code. Then fix the errors such that the program compiles and runs. Explain the motivation of your modifications in the code and their effects on the execution inheritance.cpp file #include<iostream> using namespace std; class A { int x; public: void setX(int i) {x = i;} void print() { cout << x; } }; class B:...

  • C++ problem a 6. 9. Read the following program carefully and answer questions. Rinclude <iostream using...

    C++ problem a 6. 9. Read the following program carefully and answer questions. Rinclude <iostream using namespace std; class Grand Parent public Grand Parent cout "Grandparent constructor! <<endl. class Father public GrandParent public: Father Grandparent cout "Father Constructor Kendl. void cout In Father functiob <<endl y virtual void cout In Father, y function <<endl i class Mother public Grand Parent public Motber() Grandparent() cout Mother Constructor <<endl void cout "In Nother, x function <<endli yo void y() cout <<"In Mother,...

  • solve it in c++ 10 note: please do not give me same answer like this 1....

    solve it in c++ 10 note: please do not give me same answer like this 1. Define a Pet class that stores the pet's name, age, and weight. Add appropriate constructors, accessor functions, and mutator functions. Also define a function named getLifespan that returns a string with the value "unknown lifespan." Next, define a Dog class that is derived from Pet. The Dog class should have a private member variable named breed that stores the breed of the dog. Add...

  • Given list.h, main.cpp, i need to write list.cpp. having a lot of problems. please help. list.h:...

    Given list.h, main.cpp, i need to write list.cpp. having a lot of problems. please help. list.h: ////////////////////////////////////////////////////////////////////////// #ifndef LIST_H #define LIST_H ////////////////////////////////////////////////////////////////////////// namespace CS170 { struct node { int value; node *next; }; class list { public: // Constructor for list. Creates an empty list list(); /* Destructor for list. Empty the list and release the allocated memory */ ~list(); // Prints out the values contained in the list void print_list() const; // Returns the current size of the list...

  • I need help solving this basic C++ question. I need help fixing my code.   Question: Design...

    I need help solving this basic C++ question. I need help fixing my code.   Question: Design a class called a box that represents a box. Box classes have variables such as the length of the box, width, and height. 1. Member variables shall be dedicated members. 2. Define the creator of the Box Class. The creator may receive all of the data and may not receive any. 3. Add accessor and creator 4. Add an empty function, which indicates whether...

  • // Inheriting member functions // Please Make all changes as noted below: // 1) Make sayHello...

    // Inheriting member functions // Please Make all changes as noted below: // 1) Make sayHello virtual function (hint this will be done in Person class // 2) Change main to create two Person pointer variables // 3) Set each pointer to one of the two objects already instantiated below // 4) Use the pointer variable to invoke the two sayHello() methods #include <iostream > #include <string > using namespace std ; class Person { protected : string name; int...

  • 4.a) 4.b> 4.c) C++ Programming Lab Exercise 09 Inheritance. Friend Functions, and Polymorphism (virtual functions) 4.a)...

    4.a) 4.b> 4.c) C++ Programming Lab Exercise 09 Inheritance. Friend Functions, and Polymorphism (virtual functions) 4.a) Run the following code and observe the output. #include <iostream> #include <string> using namespace std; class Vehicle public: void print() { cout << "Print: I am a vehicle. \n"; } void display() { cout << "Display: I am a vehicle. \n"; } }; class Car: public Vehicle { public: void print() { cout << "Print: I am a car.\n"; } void display() { cout...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT