Question: C++ C++ C++ C++ C++ 1. Define a class 81 with a virtual function vf () and a non-virtual function ft(). Define both of these

C++ C++ C++ C++ C++

1. Define a class 81 with a virtual function vf () and a non-virtual function ft(). Define both of these functions within class B1. Implement each function to output its name (e.g., Bl: :vf (). Make the functions public. Make a B1 object and call each function.

2. Derive a class D1 from 81 and override vf(). Make a D1 object and call vf 0 and 10 for it.

3. Define a. reference to 81 (a B1&) and initialize that to the D1 object you just defined. Call vf() and 10 for that reference.

4. Now define a. function called 10 for D1 and repeat 1-3. Explain the results.

5. Add a pure virtual function called pvf() to B1 and try to repeat 1-4. Explain the result.

6. Define a class D2 derived from D1 and override pvf 0 in D2. Make an object of class D2 and invoke 10, vf(), and pvf() for it.

7. Define a. class B2 with a pure virtual function pvf(). Define a class D21 with a string data member and a. member function that overrides pvf(); D21: :pvf() should output the value of the string. Define a class D22 that is just like D21 except that its data. member is an int. Define a function f() that takes a. B2& argument and calls pvf() for its argument. Call 10 with a D21 and a D22.

C++ C++ C++ C++ C++ 1. Define a class 81 with a

C++ C++ C++

1. Define a class B1 with a virtual fnction vf() and a non-virtual finction f). Define both of these fimctions within class B1. Implement each fimction to output its name (e.g. B1::vf). Make the fimctions public. Make a B1 object and call each fimction. 2. Derive a class D1 from B1 and override vf). Make a D1 object and call vf) and f0 for it. 3. Define a reference to B1 (a B1&) and initialize that to the D1 object you just defined. Call vf0 and fO for that reference. 4. Now define a fmction called fO for D1 and repeat 1-3. Explain the results. 5. Add a pure virtual fiunction called pvf) to B1 and try to repeat 1-4. Explain the result. 6. Define a class D2 derived from D1 and override pvfO in D2. Make an object of class D2 and invoke f0. vfO). and pvf) for it. 7. Define a class B2 with a pure virtual finction pvf(). Define a class D21 with a string data member and a member fiumction that overrides pvfO D21::pvf) should output the value of the string. Define a class D22 that is just like D21 except that its data member is an int. Define a fiunction f( that takes a B2& argument and calls pvf) for its argunent. Call f) with a D21 and a D22. 1. Define a class B1 with a virtual fnction vf() and a non-virtual finction f). Define both of these fimctions within class B1. Implement each fimction to output its name (e.g. B1::vf). Make the fimctions public. Make a B1 object and call each fimction. 2. Derive a class D1 from B1 and override vf). Make a D1 object and call vf) and f0 for it. 3. Define a reference to B1 (a B1&) and initialize that to the D1 object you just defined. Call vf0 and fO for that reference. 4. Now define a fmction called fO for D1 and repeat 1-3. Explain the results. 5. Add a pure virtual fiunction called pvf) to B1 and try to repeat 1-4. Explain the result. 6. Define a class D2 derived from D1 and override pvfO in D2. Make an object of class D2 and invoke f0. vfO). and pvf) for it. 7. Define a class B2 with a pure virtual finction pvf(). Define a class D21 with a string data member and a member fiumction that overrides pvfO D21::pvf) should output the value of the string. Define a class D22 that is just like D21 except that its data member is an int. Define a fiunction f( that takes a B2& argument and calls pvf) for its argunent. Call f) with a D21 and a D22

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!