Site icon T4Tutorials.com

Classes Objects C++ program to print the string in reverse order

Write a C++ program to print the string in reverse order using the classes and objects in object-oriented programming.

#include<iostream>
#include<conio.h>
using namespace std;
class T4tutorials
{
	private:
		string str;
		public:
			int call()
			{
	string str="I Love T4Tutorials.";
	for(int i=str.length()-1; i>=0; i--)
		cout<<str[i];
}
};
	int main()
	{
		T4tutorials obj;
		obj.call();
	}

 

Output

I Love T4Tutorials.

slairotut4t evoL I.