Write a program in C++ to print a string in reverse order by using the virtual base class in Object Oriented Programming.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
#include<iostream> using namespace std; class A { public: string str=" Welcome to T4Tutorials."; }; class B:virtual public A { public: int i; }; class C: public B { public: int show() { for( i=str.length()-1;i
>=0;i--) { cout<<str[i]; } } }; int main() { C obj; obj.show(); } |
Output
Welcome to T4Tutorials.
.slairotuT4T ot emoclew
FAQ
how to reverse a string in c++ using strrev by using the virtual base class in OOP.
reverse a string in c++ without using library function by using the virtual base class in OOP.
c++ program to reverse a string using arrayby using the virtual base class in OOP.
reverse words in a string in C++ by using the virtual base class in OOP.
reverse a sentence in C++ by using the virtual base class in OOP.
program to reverse a string in C++ by using the virtual base class in OOP.
C++ program to print alphabets in reverse order by using the virtual base class in OOP.