Answer to Question #261327 in C++ for Appu

Question #261327

 Rewrite the code in c++ using Factory Method. The goal is to remove the

main function’s dependency on the concrete classes, such as FlyToSchool,

#ifndef FLYTOSCHOOL_H

#define FLYTOSCHOOL_H

#include <iostream>

#include "GoToSchool.hpp"


using namespace std;


class FlyToSchool:public GoToSchool {

  void takeTransit() { cout << "We are taking a flight." << endl; }

  void arrive() { cout << "After 2 hours, we arrive." << endl; }

};


#endif



1
Expert's answer
2021-11-05T00:33:42-0400
#ifndef FLYTOSCHOOL_H


#define FLYTOSCHOOL_H


#include <iostream>


#include "GoToSchool.hpp"






using namespace std;






class FlyToSchool:public GoToSchool {
    public: 
        void takeTransit() { 
            cout << "We are taking a flight." << endl; 
        }
        void arrive() { 
            cout << "After 2 hours, we arrive." << endl; 
            
        }


};

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS