jweinst1
4/27/2016 - 6:46 AM

string class in c++ that allows string extension

string class in c++ that allows string extension

#include <iostream>
using namespace std;

//C++ program that manipulates a string class and gets char
class StringObj {
public:
	string message;
	StringObj(string input) {
		message = input;
	}
	void printstring(){
		cout << message << endl;
	}
	char get(int key) {
		return message[key];
	}
	void extendstr(string other) {
		message += other;
	}
};



int main() {
	StringObj lst("hello there");
	lst.extendstr(" joe");
	lst.printstring();
	return 0;
}