Where does the abstract class is used?
Pick out the correct option.
What is meant by pure virtual function?
What is the output of this program?
1. #include2. using namespace std; 3. class Base 4. { 5. public: 6. virtual void print() const = 0; 7. }; 8. class DerivedOne : virtual public Base 9. { 10. public: 11. void print() const 12. { 13. cout << "1"; 14. } 15. }; 16. class DerivedTwo : virtual public Base 17. { 18. public: 19. void print() const 20. { 21. cout << "2"; 22. } 23. }; 24. class Multiple : public DerivedOne, DerivedTwo 25. { 26. public: 27. void print() const 29. { 29. DerivedTwo::print(); 30. } 31. }; 32. int main() 33. { 34. Multiple both; 35. DerivedOne one; 36. DerivedTwo two; 37. Base *array[ 3 ]; 38. array[ 0 ] = &both; 39. array[ 1 ] = &one; 40. array[ 2 ] = &two; 41. for ( int i = 0; i < 3; i++ ) 42. array[ i ] -> print(); 43. return 0; 44. }
What is the output of this program?
1. #include2. using namespace std; 3. class sample 4. { 5. public: 6. virtual void example() = 0; 7. }; 8. class Ex1:public sample 9. { 10. public: 11. void example() 12. { 13. cout << "ubuntu"; 14. } 15. }; 16. class Ex2:public sample 17. { 18. public: 19. void example() 20. { 21. cout << " is awesome"; 22. } 23. }; 24. int main() 25. { 26. sample* arra[2]; 27. Ex1 e1; 28. Ex2 e2; 29. arra[0]=&e1; 30. arra[1]=&e2; 31. arra[0]->example(); 32. arra[1]->example(); 33. }