Posted by caiobm on Mon 23 Feb 20:06 (modification of post by caiobm view diff)
report abuse | download | new post
- #include <string.h>
- #include <iostream>
- using namespace std;
- class String {
- public:
- char *operator +(char *str)
- {
- length += strlen(str);
- return(strcat(buffer,str) );
- };
- String(char* string) {
- strcpy(buffer,string);
- length = strlen(buffer);
- }
- int getLength();
- friend ostream& operator<< (ostream& cout, String str);
- private:
- char buffer[256];
- int length;
- };
- ostream& operator<< (ostream& cout, String str) {
- cout << str.buffer;
- return cout;
- }
- int String::getLength() {return length;}
- int main() {
- String str = "aaa";
- cout << str + "vvvv";
- char c;
- cin >> c;
- return 1;
- }
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.