Answer to Question #185914 in C++ for VARUN

Question #185914

Dynamic Objects and Run Time Polymorphism

Develop a C++ program for mobile users of prepaid and postpost schemes using pure virtual functions. The mobile detail consists of data members such as mobile vendor and Branch. The prepaid account consists of data members such as prepaid_plan. The current account consists of data members such as postpaid_plan. The member functions are getdetails() and display()

Runtime Input :

Aircel

Chennai

199

499

Output :

Aircel

Chennai

199

499


1
Expert's answer
2021-04-28T17:33:57-0400
#include <iostream>
using namespace std;
class Mobile{
    protected:
        string vendor, branch;
    public:
    Mobile(){}
    virtual void getdetails(){}
    virtual void display(){}
};
class Prepaid: public Mobile{
    protected:
        int prepaid_plan;
    public:
    
};
class Current: public Prepaid{
    int postpaid_plan;
    void getdetails(){
        cout<<"Runtime Input:\n";
        cin>>vendor;
        cin>>branch;
        cin>>prepaid_plan;
        cin>>postpaid_plan;
    }
    void display(){
        cout<<"output:\n";
        cout<<vendor<<endl;
        cout<<branch<<endl;
        cout<<prepaid_plan<<endl;
        cout<<postpaid_plan<<endl;
    }
};
int main(){
    Mobile* mobile;
    mobile = new Current();
    mobile->getdetails();
    mobile->display();
    return 0;
}

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
New on Blog
APPROVED BY CLIENTS