Answer to Question #316467 in C++ for Mona

Question #316467

Write a program in C++ that defines a class named StringOps. Declare data members of

this class as described below:


ï‚· variable str of data type string.

ï‚· variable size of data type integer which represents the length of the string str.


1
Expert's answer
2022-03-23T13:45:06-0400
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;


class StringOps {
private:
	string str;
	int size ;


public:


	StringOps(string str, int size ) {
		this->str = str;
		this->size  = size;


	}


	void print(){
		cout<<"String: "<<str<<"\n";
		cout<<"Size: "<<size<<"\n";


	}




	~StringOps(){


	}




};




int main(void){
	StringOps str("String",6);
	str.print();


	cout<<"\n\n";


	system("pause");
	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